Hi im very new to C# and im trying to make a simple checkpoint system with variable positions, every time the player collides with the latest checkpoint, that will be the latest checkpoint, i got this so far:
//starting position
public float xPos = -2.005395f;
public float yPos = 0.4081692f;
public float zPos = -1.894107f;
void OnTriggerEnter (Collider playerCollision)
{
//when the player touches the 'deathcube' the player dies (works fine)
if (playerCollision.tag == "DeathCube")
{
gameObject.transform.position = new Vector3(xPos, yPos, zPos);
}
//when the player touches the latest checkpoint, make this spot the new x, y, z coordinates, need help here
else if (playerCollision.tag == "Checkpoint")
{
//how do i make this checkpoint into the new xPos, yPos, zPos variables
}
//also if u can help here, this happens when i on top of a door and i press 'up' but it doesnt work very well, only on extremely precise spots, (its a square, with a square collider).
else if (playerCollision.tag == "Finish") && (Input.GetKeyDown("o")))
{
gameObject.transform.position = new Vector3(27.79584f, 9.437206f, zPos);
}
}