Created
May 28, 2021 20:10
-
-
Save yanniboi/8c29f51a3defad38952328f0c5b99440 to your computer and use it in GitHub Desktop.
Spike Collider for longy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SpriteChange : Monobehaviour | |
{ | |
public Sprite[] spriteArray; | |
public Sprite spikeSprite; | |
public SpriteRenderer spriteRenderer; | |
public int currentSprite; | |
private void OnCollisionEnter2D (Collision2D col) | |
{ | |
if (col.gameObject.tag == "spike") | |
{ | |
spriteRenderer.sprite = spikeSprite; | |
} | |
else | |
{ | |
spriteRenderer.sprite = spriteArray[currentSprite]; | |
currentSprite++; | |
if (currentSprite >= spriteArray.Length) | |
{ | |
currentSprite = 0; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
so now for some reason the spike destroys the heart all together and still when i collide with the floor the sprite changes