When I started my unity game it suddenly rotate -90 it self on Z position, how can I fix it? please help.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PathCreation;

public class path2 : MonoBehaviour
{
public PathCreator pathCreator;
public float speed = 5;
float distanceTravelled;

void Update()
{
    distanceTravelled += speed * Time.deltaTime;
    transform.rotation = pathCreator.path.GetRotationAtDistance(distanceTravelled);
    transform.position = pathCreator.path.GetPointAtDistance(distanceTravelled);

}

}

Found this on another forum so I can’t take any credit… but this completely fixed it for me :slight_smile:

Simply add * Quaternion.Euler(0, 0, -90); to the end of the GetRotationAtDistance method, like so:

transform.rotation = pathCreator.path.GetRotationAtDistance(distanceTravelled) * Quaternion.Euler(0, 0, -90);

You might need to play around with which axis is affected by tweaking the “-90” value, but that’s it.