|
I know there are a million other questions like this here, so sorry for being an idiot. Here goes: My character is a RigidBody ball, and I have this: ( "a < b" would mean that a is the parent of b) Ball < GameObject < Camera Ball has a simple movement script attached. GameObject has a script to stop it from rotating when Ball does. Camera has a camera movement script. Everything works right, except that the movement of Ball is not camera relative. Pushing forward always results in movement in one direction, regardless of which way the camera points. The complicating factor is that I can't simply make the y rotation of Ball equal to that of the Camera, because that would effect the physics (if you hit a wall while spinning the camera you would bounce off differently). So how do I make movement of my character relative to camera direction without rotating my character on the y axis when the camera turns? JavaScript please!!!! My movement script:
(comments are locked)
|
That should give you a world-vector for your local camera Z-Axis vector times ten. Where do I apply that script? BTW I added my movement script to the question, that may help you answer...
Dec 20 '10 at 06:29 AM
DonGato
impulseDirection should be in your rigidbody.AddTorque(). Right now you are adding torque in the world axes rather than on the local axes. You could use AddRelativeTorque instead with the code you already have (I assumed you were using forces). Try both ways...
Dec 20 '10 at 01:14 PM
The_r0nin
Ok problem solved... Basically I ended up using a modified version of the example script under TransformDirection in the scripting reference. Without you I may not have found out about TransformDirection, so Thank You!!!
Dec 20 '10 at 06:04 PM
DonGato
(comments are locked)
|
|
also you can go.. both give transform relative vectors
(comments are locked)
|
