ball game question

Hi,

I made a simple game where you just roll a ball around on a track. But now I have a question. If I’m rolling the ball down a track, and the track makes a 90 degree turn I have to move the ball sideways to go forward. So, I was wondering if it would be possible to have the camera pan with the mouse and then, when the forward key is pressed, have the ball move in the direction the camera is pointing, instead of in a global direction? (If my question didn’t make any sense, I should be able to post a picture to better explain things)

Any help would be appreciated,
Peter

there is global and local settings for force and orientation, in this case i think you want to rotate global, but move local.
are you using 2.49 or 2.5x?

in 2.5x, http://www.blender.org/documentation/250PythonDoc/bge.types.html#bge.types.KX_GameObject
worldOrientation or applyRotation( [], false) for rotations
applyForce( [], true) or applyMovement( [], true) for movements?

hmmn. if you want to only be able to press forward, and move round a track (without pressing turn buttons)
i have made a solution.
It consists around tracking to nodes (empties) around the corner.
if not, on the movement actuator select the little L which makes the movement affect the object on its local axis

I dont know exactly what u asked for, but I hope I am right:

on your actuator that tells the ball to move forward, on the right side there is a “L” this is toggled between local and global, just test it

if u want the camera to follow the ball (if u asked for that, im not sure) u can parent it , just right click on the ball (if ur model is rigged its better to right click on the armature
and not the model) and then shift + right click on the camera and press ctrl+p to parent it, every movement the ball makes is copied by the camera

I hope I helped :slight_smile:

Thanks for the replies!:slight_smile:

agoose77
hmmn. if you want to only be able to press forward, and move round a track (without pressing turn buttons)
i have made a solution.
It consists around tracking to nodes (empties) around the corner.

My track is more like a channel that the ball rolls down, so I don’t know if tracking to nodes would work very well.

on your actuator that tells the ball to move forward, on the right side there is a “L” this is toggled between local and global, just test it

I think using the objects local axis would work if it was something like a cube, but because I’m using a sphere, it just kind of jiggled around when I had it on local.

Here is a picture of the way it is and the way I want it to be.


It’s like I need to apply force to the ball along the camera’s local axis.

I have a marble game on my computer like this, but I don’t know if it can be done using blender’s game engine.

because the ball is rolling local axis wont work. :confused:
this is a tricky one.
i have an idea.
have a ball that is vertex parented to an empty.
then the ball can move freely, but be pulled by the empty. and not rotated? then the empty can track around a corner, and pull the ball in that direction

if u want to make the ball realistic dont parent it to empty, just make it dynamic so when u force it to move it will rotate like a norma ball

that’s what i thought

Thanks for your help guys.

I tried pushing the ball around with an empty but I couldn’t get it working very well. I think I have thought of a possible solution though. It has to do with the fact, that if applied equal force on both the X and the Y axes, the ball would move in a 45 degree angle.


All that I would need is a python script that got the angle the camera was pointing, and then have it calculate what proportion of X and Y force to apply, to move the ball in that direction.

I will post the python script if I get it working.

how do u make nodes

how do u make nodes

Bit off topic really…

What I did for a simple ball game was to have an empty that actually moved, and then just have the ball rotate in roughly the right direction. It was enough to fool the eyes, but the ball actually didn’t move anything, only the empty

On another thought: Why is it that a marble/ball rolling game is one of the ones that many people want to make?