|
I am trying to get an object like an arrow to point in the direction it is moving. I am using this code from the Roll a Ball tutorial. Any ideas?
Thanks
(comments are locked)
|
|
Use this:
Note that if you make the object always face in the direction of movement this way, it won't be rolling anymore (of course) so that may affect the physics if you were relying on a rolling behaviour. You could instead still have a round collider that is rolling, and have your visible object be a child object of that, and use the LookRotation function on that child, so the visible child (without a collider) is pointing in the direction of movement while the invisible parent (with a collider) is rolling freely. Edit: Actually, you may want to use this to avoid very fast rotations, or errors if the object is standing still: This is exactly what I needed. Thanks
Feb 09 '11 at 02:04 PM
Richard 3
Is there anyway to maintain it's last faced direction even after no Input?
Jul 18 '11 at 06:30 AM
pikpiak
(comments are locked)
|
|
Here's another solution that will look in the direction the ball's moving, not the direction of input. Good for attaching a hat/gun to the ball or something.
Now just make your arrow model a child of this GameObject. Move the Z position out as far as you want the arrow to appear.
(comments are locked)
|
