i currently have a mathclamp on my player as a movement boundary, everything is working fine but when i trigger the players death(when he hits the enemy collider) and i respawn the player, he respawns in the same position that i initially had him but the value of x is 5 instead of -5, the values in mathclamp are still the same but the relative world position(transform.position) of my player seems to be different, please help i have no idea whats doing it been at it for hours.
here is my code for the boundary
public class Boundary
{
public float xMin, xMax, yMin, yMax;
}
public class Movement : MonoBehaviour
public Boundary boundary;
public Vector2 playerSpawn;
rigidbody2D.position = new Vector2
(
Mathf.Clamp (rigidbody2D.position.x, boundary.xMin, boundary.xMax),
Mathf.Clamp (rigidbody2D.position.y, boundary.yMin, boundary.yMax)
);
if (Input.GetKeyDown (KeyCode.R))
player.transform.position = playerSpawn;