rotate projectile

All my projectile uses is AddForce and gravity. The direction in which Y is pointing is how my rocket launches. So essentially the tip of the rocket points where the Y is pointing. So say when the rocket approaches the ground the tip of the rocket should be rotated towards the ground. I attached a screenshot. Showing the direction of launch.

You could use a Phyisics.OverlapSphere to detect if the ground is within a certain radius, and then rotate towards that object if it is the ground. (You can put the ground on a separate layer.)

If you want the projectile to look in the direction that it is flying in, an arc essentially, you could try rotating the projectile slightly over time, at a speed, and adjusting it until it matches your arc. For example:

public class Projectile : MonoBehaviour
{
    public float RotationSpeed;

    void Update()
    {
         transform.localEulerAngles = new Vector3
         (
             transform.localEulerAngles.x,
             transform.localEulerAngles.y + RotationSpeed,
             transform.localEulerAngles.z
         );
    }
}

This script rotates the projectile on the y axis gradually at a set speed, which you can adjust, until its rotation speed matches up with what you think the arc should look like.


This may vary depending on the speed you fire your projectile, and its arc, and so you could possibly do some calculations to find a sweet spot, or an equation to find a perfect rotation speed, no matter the arc. @gamedevunity12