How to set player position to a specific position?
I want to make the following thing.
When the player colide with a entrance collider, the player will be moved to the exit point.
I move the player object to the exit point position and know that the transform position is
(-8.439795, -0.1257886, 13.56904)
.I use code
player.transform.position = new Vector3 (-8.439795f, player.transform.position.y, 13.56904f);
to do the task.When the player colide with a entrance collider, the transform.position of the player become
(-4.953017f, 0.1186209f, 9.465188f)
. That position is not the exit point.
The the player object is a child of other objects. How to solve this problem?
use transform.localposition = new vector3(give your values);
ins$$anonymous$$d of transform.position
Answer by Veerababu.g · Mar 30, 2016 at 12:22 PM
if your player having any parent then it'll behave like that
How can I solve it without the need of removing the parents? Think you. Update: When I use player.transform.localPosition = new Vector3 (-8.439795f, player.transform.position.y, 13.56904f);
the position is still not accurate.
Your answer
Follow this Question
Related Questions
Get coordinates of mouse-click on plane 1 Answer
Remember position for a simple player controller (Left/Right)? 0 Answers
How to prevent the player to move beyond certain x-position value 3 Answers
Vector3.Lerp not working properly, making the player bounce around 2 Answers
Get position.x from when touching or holding the finger 0 Answers