Quantcast
Channel: Latest Questions by orcinusdev
Viewing all articles
Browse latest Browse all 26

transform.position sends object to wrong position

$
0
0
I have a really simple code where a player enters a collider (teleport) and gets moved to another position. When i look in the unity editor, its position is not what I assigned it to (it moves to some place between the right position and the teleport. I'm not using any child objects. Here is the code assigned to the teleport object. void OnTriggerEnter(Collider collider){ if(collider.gameObject.CompareTag ("Player")) { Teleport(); } } void Teleport() { PlayerController.pc.myTransform.position = new Vector3(10f, 10f, 0f); PlayerController.playerSpeed = 0; } } (I got the same results without the teleport method where I just implement the teleport code in the OnTriggerEnter method) I have tried localPosition aswell. For the player I just have a translation code in the update method and code for rotation based on user input. Do anyone have a solution for me? Its landing position can differ widely, it can be close to the right position or close the the teleport, which is very very strange Thankfull for help

Viewing all articles
Browse latest Browse all 26

Latest Images

Trending Articles





Latest Images