Hello Community,
I’m trying to change the y and z axis of my player at the same time as the player move up and down. Problem is at first only the z axis is getting added and the y remains the same.
The following is in a function being called in my FixedUpdate() function. The player will move and if I look at my inspector, after I stop, the y and z are the same.
I am using the z axis later to help me calculate a jump as the z stays where the ground is and the y is where the player is but the code returns this same issue.
Debug.Log("vertical: " + vertical);
movement.Set(horizontal, vertical, vertical); // z axis is to place which character is in front
movement = movement.normalized * speed * Time.deltaTime; // make sure player isn't passing max speed and doesn't move per frame
Debug.Log("movement: " + movement);
Debug.Log("player's first position: " + transform.position);
transform.position += movement; // Move the player
Debug.Log("player's updated position: " + transform.position);
For the first movement I do the Log Shows:
vertical: 1
movement: (0.0, 0.1, 0.1)
player’s first position: (-2.5, 0.0, 0.0)
player’s updated position: (-2.5, 0.0, 0.1)