It may seem a little confusing, but the cupe is the “car”,
and i want the gravity to always face the normals of the track
I tried this script, but with no luck
import GameLogic as GL
from Mathutils import Vector
scene = GL.getCurrentScene()
cont = GL.getCurrentController()
own = cont.owner
GRAVITY = 9.8
for obj in scene.objects:
if "gravity" in obj:
# Get vector to planet center
down_vec = Vector(obj.getVectTo(own)[1])
# Apply force in that direction to simulate gravity
down_vec.magnitude = GRAVITY
obj.applyForce(down_vec.xyz)
Byy the way, I have the impression, that all your “gravity” objects add a force (like infinite magnets).
Are you sure that the combined force is correct?
Maybe you should consider the distance to the objects as well.
Monster have right. This script is to simulate planetary gravity. The gravity is always pointed to the center (pivot point) of your track. So I think this script did not work for you.
The easiest way to do this is to disable the world gravity and add a motion actuator to your car. On the motion actuator apply a local force in minus Z direction so the car is always be pulled down to you track.
Yeah I tried what you said HG1, here’s a simple file…
WASD to move, left and right arrow to turn and spacebar to float into zero gravity
There are still some bugs, I think there would be a script needed to work seamlessly…
Regards,
Luke
I looked on the file and i think it is working good. I only locked the rotation on the Z axis. And I thought you want to make a racing game where you only drive on a track and not on a planet. When you you have later a car with wheels, the car would work seamlessly. If you want to make later a pod-racer you can try to stabilize it with four ray sensors. So you need to explain what bugs you mean and what improvement you want?