Hello,
I am still fairly new to c# and unity, but I feel like this should be working fine. Here is my problem. I am trying to tell if an actor has moved, and if he has then I am changing scenes. However, everytime I push the play button, it automatically loads the next scene even if he doesn’t move. Here is my code.
using UnityEngine;
using System.Collections;
public class CueBattle : MonoBehaviour {
Vector3 curposition;
Vector3 lastposition;
void start ()
{
curposition = new Vector3(transform.position.x, transform.position.y, transform.position.z) ;
lastposition = new Vector3(transform.position.x, transform.position.y, transform.position.z);
}
void Update () {
curposition = transform.position;
if (curposition != lastposition)
{
Application.LoadLevel ("BattleGrass");
}
lastposition = curposition;
}
}
I am attatching this to my main actor who has a move script attatched to him, but he only moves when left right up or down is pressed. I am not pressing a key yet its still executing the Application.LoadLevel function. Any ideas what I’m doing wrong?
Thanks for your time.