Player GameObject not updating position in game after position reassignment in script


else
{
Debug.Log("Deployed: True");
if (clonedHusk != null)
{
Debug.Log($"Husk exists. sP P: {spawnPosition.position} sP R: {spawnPosition.rotation}");
Debug.Log($"Husk P: {clonedHusk.transform.position} - Husk R: {clonedHusk.transform.rotation}");
spawnPosition.position = clonedHusk.transform.position;
spawnPosition.rotation = clonedHusk.transform.rotation;
Debug.Log($"Name: {spawnPosition.gameObject.name}");
Debug.Log($"Husk being destroyed. sP P: {spawnPosition.position} sP R: {spawnPosition.rotation}");

Destroy(clonedHusk);
Debug.Log($"Husk destroyed - sP P: {spawnPosition.position} sP R: {spawnPosition.rotation}");
isDeployed = false;
}
}

I have a GameObject Transform spawnposition. This spawnposition is the player, where the husk will be spawned. Whenever I call this function, the rotation is updated, but the position is not. The Debug.Log says that the position has been changed to where the husk was, but it doesn’t update in the game scene. How do I get it to change positions?

I would look at whether any other code is also changing just the position of the object. Maybe something in another script, like maybe something in Start on some script on the spawned object.

Your code also confuses me a little, but maybe it’s fine. You’re assigning the clonedHusk’s position and rotation to the spawnPosition object. I would normally expect it to be the other way around. But I guess when the husk dies, you’re just keeping track of its position and rotation in spawnPosition, so you can do something with that later?

CharacterController can cause this issue. Does your character have a CharacterController on it?