I have a PAWN object that has move animation from one location to another, it works fine, but after the animation I position the PAWN as a child to that object, it works fine but the PAWN teleports briefly to other location and comes back.
Animation Plays well,but teleportation effect happens briefly when parenting the object to other obj
Using transform.SetParent(parentObject, true);
with the “worldPositionStays” overload set to true (where I put true in the example) might fix that issue.
no bro ,same problem
here is the code
//GetChild(3) = Centre of the object
player1.transform.SetParent(tilePosition[playerOne_CurrentPos - 1].transform.GetChild(3).transform, true);
//player1.transform.parent = tilePosition[playerOne_CurrentPos - 1].transform.GetChild(3).transform;
player1.transform.position = player1.transform.parent.position;
if (playerOne_CurrentPos == playerTwo_CurrentPos)
{
player1.transform.SetParent(player1.transform.parent.transform.parent.transform.GetChild(1).transform, true);
//player1.transform.parent = player1.transform.parent.transform.parent.transform.GetChild(1).transform;
player1.transform.position = player1.transform.parent.transform.position;
player2.transform.parent = player2.transform.parent.transform.parent.transform.GetChild(2).transform;
player2.transform.position = player2.transform.parent.transform.position;
}
else
{
player2.transform.SetParent(player2.transform.parent.transform.parent.transform.GetChild(3).transform, true);
//player2.transform.parent = player2.transform.parent.transform.parent.transform.GetChild(3).transform;
player2.transform.position = player2.transform.position;
}
may be a problem in animation?
Unfortunately, I have no idea what I’m looking at.
Is there a reason you’re setting a property to itself on lines 12, 15, and 21? Does that do anything?
ah, changed the code, it is parents position, my bad