Reputation: 1
I created a simple shooter in Unity and i want to change the position of my Player (FPSController). I can only change the position when i do it in the Prefab but this is useless for me. If i call functions like "InstantiatePlayer()" where it tries to change the position, the player will be teleported after 0.1 sec back to the old position.
public void InstantiatePlayer()
{
GameObject temp = Instantiate(PlayingplayerPref);
temp.transform.position = new Vector3(31, 6, 7);
}
Upvotes: 0
Views: 97
Reputation: 820
vgro's solution is ok, but instead of creating a new Quaternion you should use Quaternion.identity, won't do much of a difference here but it's good practice
Upvotes: 1
Reputation: 488
You can specify the position when on instantiating.
Instantiate(Object PlayingplayerPref, Vector3 position, Quaternion rotation);
If you dont want to specify the rotation just set the quaternion to (0,0,0,0), so you will have
Instantiate(PlayingplayerPref, position, new Quaternion(0,0,0,0);
Hope this helps :)
Upvotes: 0