- Home /
,Sprite disappeared on positive y axis 2d unity
,I'm making a game in unity2d and i have an enemy, that is using the A* AI to follow my player, and I have a separate sprite to do the animations that I'm planning to do ,it only has one animation now, but the sprite disapears when going above the global x axis in the game view and in the scene. The sprite has a positive y value at that moment. This is my code:
private Vector3 LastLocation = Vector3.zero;
private Transform target;
void Start()
{
target = GameObject.Find("Enemy").transform;
}
void Update()
{
transform.position = target.transform.position;
Vector3 curVel = (transform.position - LastLocation) / Time.deltaTime;
if(curVel.y > 0)
{
// it's moving up
Debug.Log("moving up");
} else {
// it's moving down
Debug.Log("moving Down");
}
if(curVel.x > 0)
{
// it's moving right
Debug.Log("moving right");
} else {
// it's moving left
Debug.Log("moving left");
}
LastLocation = transform.position;
}
Can someone help me? Thanks in advance!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Gun is not rotating while player is in a animation 0 Answers
Distribute terrain in zones 3 Answers
2D Animation - Animation Goes Extremely Fast 0 Answers
How to change animation's speed in C#? 2 Answers