This site requires JavaScript, please enable it in your browser!
Greenfoot back
Max0309
Max0309 wrote ...

2021/3/24

My Enemies (Bots) float in/through Objects

Max0309 Max0309

2021/3/24

#
Yeah the problem is like already in the headline. I don't know how to make it, that they just cant walk in it. I did it for the player I play, but I can't for the Enemies. My Project: https://www.greenfoot.org/scenarios/27560 Would be niiiice if you could help me there. (We are talking about Enemy and Enemy2) but I guess it's just copy'n'paste there if you got it for one... Thank you already
Super_Hippo Super_Hippo

2021/3/24

#
You should have answered to your other message instead of creating a new discussion. I am using this now even though it doesn’t have the code included because this one has a useful title. You can use this line before checking for a hit (after line 35) from the code you showed in the other discussion.
1
if (checkCollision()) setLocation(x, y);
However, you will see an issue that the player also has. If it tries to move to a place it can’t reach, it stays where it is. If you are for example on the left edge (as the player) and press W and A (up and left), you are not moving at all. If you handle horizontal and vertical movement separately, you could move up in this case. Then the enemies could also move instead of being slowed down.
You need to login to post a reply.