C
C#2y ago
_arira_

❔ Having trouble with a player swap function

public void swap()
{
Vector3 LastPlayerPos = transform.position;
transform.position = Clone.transform.position;
Clone.transform.position = LastPlayerPos;


}
public void swap()
{
Vector3 LastPlayerPos = transform.position;
transform.position = Clone.transform.position;
Clone.transform.position = LastPlayerPos;


}
basically here i take the player position when the function is called and incorporate it in a variable (LastPlayerPos) Then i switch the player position with another gameobject (cloneposition) and swap the position of the clone with the lastplayerpos. It doesnt work tho, the clone teleport to the player but the player doesnt teleport to the clone. Does anyone know why?
2 Replies
Susko3
Susko32y ago
if you make the transform.position = new Vector3(100, 100, 100) will the player teleport to coordinates 100, 100, 100?
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?