Game Concept Help!

Hi guys,

i’m trying to help someone out who wants to make a 3D game but isnt sure how the scripting will work. Basically he plans to have a series of trays with balls in and a golf style hole to aim for. Then he has a camera focused on the ball, which rotates around it at all times, and upon triggering a function, he wants to apply a force away from the camera, as if its being pushed by the player who is facing it, by doing this, eventually the player should be able to “pot” the ball, letting it drop through to the next part of the puzzle. I’ve told him the way I would attempt it, which is to use the camera’s forward vector in order to change the axis of the ball, then apply a velocity using the forward direction of the camera. Does this make sense or is there a better way of doing it? He has given me a grab of the 3d tray - its just a 3D test in director currently, just so you can get an idea of what i mean. Take a look and any help would be much appreciated!

Cheers,

Will

24546--883--$tom_151.png

I would make sure to keep the velocity vector constrained to 2D so you don’t end up shooting the ball weird. So just use the camera’s Y rotation (theCamera.transform.eulerAngles.y) to apply to your objects rotation.

The step by step way that I can think of to do is:

1: Get the camera’s y rotation as above
2: set your ball’s y rotation to the camera one
3: use transform.TransformDirection(Vector3.forward) to get the forward vector of your ball
4: then add your force in that direction.

I am half-asleep right now, so if I missed something or am being dumb…don’t yell at me. :wink:

-Jeremy

Jeremy,

fine work sir, thats really helpful, i’ll give your procedure a try once im back at work (its my birthday so im off to GAMEON in london…yay!) and get back to you. cheers again,

Will

Well Happy Birthday then!

-Jeremy