A problem of solids.

0 favourites
  • 5 posts
  • Hi, I have a player solid object, and some solid enemies objects.

    These enemies, whenever I am close to them, they start start to chase me.

    The thing is that if I quiet (don't move), they eventually come to me, and PUSH me.

    Is there any way to make them not to push me?

  • Because both your player and enemy have solid behavior, so it's a reason when enemy come and push your player.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • There is probably a lot of different methods, heres two I use though.

    First you use an invisible sprite that is bigger than your player sprite and then set its position to your player. Then you give your enemies commands that once they are "overlapping" the sprite that their speed will be reduced to 0, stopping them.

    Another way is with the distance checks. For example your condition could be; Distance(player.x, player.y, monster.x, monster.y < your desired distance you want them to stop. And then the action could be again to set the speed to 0.

    Just remember if you want them to start running again once you move away - then you need to tell them what to do as well. IE, invert the condition and set the speed to their regular speed again.

  • There is probably a lot of different methods, heres two I use though.

    First you use an invisible sprite that is bigger than your player sprite and then set its position to your player. Then you give your enemies commands that once they are "overlapping" the sprite that their speed will be reduced to 0, stopping them.

    Another way is with the distance checks. For example your condition could be; Distance(player.x, player.y, monster.x, monster.y < your desired distance you want them to stop. And then the action could be again to set the speed to 0.

    Just remember if you want them to start running again once you move away - then you need to tell them what to do as well. IE, invert the condition and set the speed to their regular speed again.

    Thanks a lot,

    I'm going to give it a try.

    Indeed I was trying to do it comparing distances, but I guess I had it done wrong.

  • Okay, I'm having a problem.

    I've been doing the chasing system this way:

    if (player.x - spearman.x) > 0 --> spearman.x += 1; set mirrored.

    if (player.x - spearman.x) <= 0 --> spearman.x -= 1; set not mirrored.

    Same thing done with Y coord, as I'm doing an isometric game.

    This way, it compared positions, and the enemy sprite turns accordingly towards my character.

    Of course, doing the "set speed 0" thing won't work, as the enemy will still be moving by coordinates.

    I guess I have to do something like this:

    if (player.x - spearman.x) && (Distance(player.x,player.y,spearman.x, spearman.y) >= 30) > 0 --> spearman.x += 1; set mirrored.

    This way, it will only come to me when it's further than 30px from me, I guess.

    However, I can't manage to get the syntax correctly. >.<

    EDIT: Nevermind. Think I got it working :D

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)