Question by
codedbythet · Nov 13, 2020 at 11:31 PM ·
scripting problemcollisiontriggerspawningrespawning
Checkpoint and Respawn
I have two scripts. One is a Checkpoint controller and the other is a LevelManager.
The Checkpoint part Works.
void OnTriggerEnter2D(Collider2D other) {
if(other.tag == "Player") {
checkpointSpriteRenderer.sprite = YellowStar;
checkpointReached = true;
}
}
The respawn works.
private void OnCollisionEnter2D(Collision2D collision) {
if (collision.gameObject.CompareTag("FallZone")) {
Destroy(gameObject);
//GameControlScript.health -= 1;
ManagerPlayerHealth.health = Mathf.Max(ManagerPlayerHealth.health - 2, 0);
LevelManager.instance.Respawn();
}
The problem I am having is that when I walk in to the Checkpoint, the script records the x,y,z axis but when re-spawning, it goes to a initial re-spawn point.
What am I missing that will not allow me to change the re-spawn position?
Comment