Hey, I need to make an object(the player) to get the rotation of the Rail(a prefab object in game). The script I have now, is the player reacts onTrigger(the rail is the trigger).
In the rail this is the code:
public Vector3 ChangeRotation = new Vector3();
And in the start:
ChangeRotation = transform.rotation.eulerAngles;
And in the player:
`
public class PlayerMove : MonoBehaviour {
public GameObject Rails;
public GiveRotation getrotation;
public Vector3 NewRotation = new Vector3();
// Use this for initialization
void Start () {
getrotation = Rails.GetComponent();
}
// Update is called once per frame
void Update () {
transform.Translate(Vector3.forward*Time.deltaTime);
}
void OnTriggerEnter(){
Debug.Log("HEllo");
NewRotation = getrotation.ChangeRotation;
transform.Rotate(NewRotation, Space.Self);
//Quaternion.RotateTowards(transform.position,NewRotation,90);
}
}`
However this just makes the player move strange.