- Home /
Help with local and world translation.position
I have a fruit that i want to make the character run into. When he does, it places the fruit on top of the player and then he can run with the fruit. I placed a second fruit and rotated it 90 degrees on the x axis. I used the same code for the two fruit but the second rotated fruit now translates the wrong way.
It instead goes beneath the character. I think it is because its arrows for translation are local to the object. the y is facing in the z and the z in the y. I am using transform.position instead of the local version. What can i do to modify the code posted below so that the fruit moves on the global translation.
This is the code used in the fruits update method. It checks if the fruit has been picked up. And if so execute this code.
transform.position = new Vector3(playerobject.transform.position.x, playerobject.transform.position.y + fruitreference.y, playerobject.transform.position.z);
Thanks
I'm not shure but maybe can work if you change the local to global on the unity tools
Your answer
Follow this Question
Related Questions
Simulating different gravity, how to make falling platform fall in the desired direction? 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
use world axis when using transform.rotate 0 Answers
Transform global quaternion from local quaternion 2 Answers
Vertex Coordinates to Global Vector3 2 Answers