AI Problem

0 favourites
  • 7 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • The problem is that the Enemy is overlapping with the Player and the Friend overlapping with the Enemy.

    Here is the capx: Here

  • Please be more specific.

    What is the expected behavior you expect out of your code ? How is it different from the result you have ?

    As I see it actually, your ennemy has bullet behavior in direction of the player and your friend has bullet behavior in direction of the ennemy.

    When they collide, they are moved 2 pixels back. As programmed in your code.

    What are you trying to do precisely ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • when they collide it has many bug's. It look's like they have been shaking with each other. But I don't want that. I want that if the enemy is near the player then he should stop and vice-versa.

  • Your shaking/twitching weirdness is caused by your "Friend on Collision with Enemy" Event which just jumps your Friend 2 pixels up and to the left of your Enemy whenever there's a collision. Since you Enemy is constantly moving, your Friend will continue to shake-twitch.

    and...

    Since you're setting your Enemy and Friend speed every tick, they're NEVER gonna stop moving. You have to find a different way to move them if you ever want them to stop moving.

  • I can't open capx cause I'm at work right now .. but maybe my thoughts can help you a bit.

    I made once a game where the enemys are trying to ram you and I had the same problem you mentioned with the shaking. I also made the "teleport back" thing but also added a "set speed to 0" than "wait 1s" and "set speed to x" (whatever you want to have).

    This was kind of nice because the enemy is attacking you and stands still for a sec and than tries to attack again.

    If you want a follower than you could make an extra collision box bigger than your hero and make "if overlap" (the AI with the invisible box) "Set speed to 0" and "if NOT overlap" (the AI with the invis box) "set speed to x" (the speed of the AI). This results in your AI to follow you but never ram and shake.

    Hope that this could help you!

    Best regards

  • thank you Spades very much. It works flawlessly. Again thanks.

  • Your welcome =)

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