Enemies/interaction


I implemented my enemies and coins and the interactions between them and the player. I had some issues with getting the coins to work. I wanted the coins to need to be collected before you could finish the level. I made it so the player destroyed the coins when they hit them. I made it so my exit only worked when all the coins were gone. I did this by essentially saying if player collides with exit sign and object name coin equals null load next scene. This worked fine for one coin but it did not work for more coins. Eg you could get one coin, then get the exit. I finally worked out what the problem was. My coins were called different things. The first one was called coin but the second one was called coin(1). As I was only checking whether coin was null it didn't work. To fix it I simply renamed all my coins as coin. I then implemented my enemies. My enemies are blue, red, yellow and green. I made my enemies different colours so it was easy to tell the difference between the enemy types. I made the blue enemies move back and forth, the red enemies shoot, the yellow enemies move and shoot and the green enemies follow the player. One issue I had was the enemy spinning after it hit a wall. I used the freeze rotation in z checkbox to fix this. After I implemented the abilities of my enemies I my noticed they could collect the coins for the player. To fix this I created an enemy layer and a coin layer. Then I told the physics system to inform collisions between the two layers. I also play tested my game to make sure all levels were possible with my enemy placements.

Files

restart.zip Play in browser
Sep 17, 2020

Leave a comment

Log in with itch.io to leave a comment.