Answer the question
In order to leave comments, you need to log in
How to check if x or y is increasing?
Hello. I have a player movement script in Unity and I need to write true when x or z changes in bool value . For example:
float x,z;
bool isMoving;
if(x (здесь проверка) || z (здесь проверка) ){
isMoving = true
}else {
isMoving = false;
}
Answer the question
In order to leave comments, you need to log in
If you need to keep track of transform.position.x then through a comparison on each frame. If someone from the outside gives you a position (for example, a server, or a controller), then you can make x a property and add a check to set, like
private float x = 0;
private bool b = false;
public float X
{
get { return x; }
set { b = value != x; x = value; }
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question