Comparing 2 positions need help
here is the code from update function:
if(canMoveUp == true)
transform.Translate(Vector3.up * (verticalSpeed * Time.deltaTime));
//UpButton
if(upButtonClicked == true)
{
if(this.transform.position.y > playerPosition.transform.position.y+4.0f)
{
canMove = true;
verticalSpeed /=3;
upButtonClicked = false;
}
}
and other function:
function GoForward()
{
// if(canMove == true)
// this.gameObject.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y +4, this.gameObject.transform.position.z);
playerPosition.transform.position = this.transform.position;
upButtonClicked = true;
canMove = false;
verticalSpeed *=3;
}
Im trying to make my player to go forward with fasten speed until it reaches the position i want ( +4 on y) why isnt the if statement not working in update function?
Comment
Your answer
Follow this Question
Related Questions
Comparing 2 positions need help 0 Answers
comparing two gameobject 1 Answer
How to compare limits for creating new objects in world space? 0 Answers