If the player either collides with block 1 or collides with block 2, block 1 respawns. But that doesn’t work with my “or” statement in there. Block 1 only respawns when player collides with block 1.
Something in those lines are messing up.
The debug line I have does read “collided with block 1”, “collided with block 2” depending on which one I hit. Block 2 does the respawning when I hit it, not block 1. Block 1 is supposed to respawn when I hit block 2, block 2 shouldn’t be respawning.
//BLOCK 1 RESPAWN
[SerializeField] Transform Respawn1; //block1 respawn
private void OnTriggerEnter2D(Collider2D col)
{
if (col.gameObject.name.Equals("Block 1") || col.gameObject.name.Equals("Block 2"))
{
col.transform.position = Respawn1.position; //respawn block 1
alright so something in those lines are messing up. The debug does read "collided with block 1" , "collided with block 2" depending on which one I hit. Block 2 does the respawning when I hit it, not block 1. Block 1 is supposed to respawn when I hit block 2, block 2 shouldn't be respawning.
– SuperCrow2I found a fix. I put a public game object, then I dragged block 1 into it in the inspector, so when player hits block 1 or block 2, block 1 respawns. private void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.name.Equals("Block 1") || col.gameObject.name.Equals("Block 2")) { col.transform.position = Respawn1.position; //respawn block 1 then in this line here, "col.transform.position = Respawn1.position; //respawn block 1" I replaced "col" to whatever I named my game object
– SuperCrow2