How to define the forward direction of an object made in blender
I imported a missile object that I made in blender, and I have this script that makes it track the player. The object moves just fine but it moves with its back end first. So it basically looks like its flying backwards. Is there a way to define the forward direction of an object or change the script so that it flies like it's supposed to?
This is the script I'm using for the missile: public class Track_Player : MonoBehaviour { public Rigidbody rb; public Transform player; public float turn; public float speed;
void Start()
{
}
// Update is called once per frame
void Update()
{
rb.velocity = transform.forward * speed;
var missileRotation = Quaternion.LookRotation(player.position - transform.position);
rb.MoveRotation(Quaternion.RotateTowards(transform.rotation, missileRotation, turn));
}
}
Answer by streeetwalker · Sep 20, 2020 at 07:31 AM
the easiest way is to parent your missile to an empty game object and orient the missile so forward within the parent. Put your Rigidbody on the parent instead, and reference the parent for any motion or other transformations you need to apply.
Your answer
Follow this Question
Related Questions
Problem with the cloning object :( 0 Answers
I want Script To Move a object from a different object (In four Different directions,Randomly) . 0 Answers
making object move forward 0 Answers
JavaScript Problem - BCE0043 - Unexpected Token Help 0 Answers
How can i check if the alpha color or the material color is transparent ? 1 Answer