Hi, i am trying to get a bullet to rotate as it moves and is affected by gravity.
So if the bullet speed in 0m/s it will just rotate 90degrees and fall straight down.
My plan was to “make” a triangle of the “start” and “end” position of the bullet, ofc the start and end position changes alot during the bullets flight.
//This would be the maximum speed of you bullet
float maxSpeed = 900;
//This is where the bullet was last frame
Vector3 lastPos;
void Update () {
//Find the velocity in m/s
float velocity = (lastPos - transform.position)/Time.deltaTime;
//Set up a ratio that will be used to rotate the bullet. If the velocity is maxSpeed, then the rotation will be 0 (forward, else it will rotate towards facing down (Assuming that +Z is your forward axis)
transform.eulerAngles = new Vector3(velocity/maxSpeed * 90, transform.eulerAngles.y, 0);
//Set lastPos so we can get the velocity next frame!
lastPos = transform.Position;
}
Very rough, but if you implement code like this, it should do what you asked!