AI Problem

Discussion and feedback on Construct 2

Post » Mon Oct 03, 2011 6:46 pm

The problem is that the Enemy is overlapping with the Player and the Friend overlapping with the Enemy.

Here is the capx: HereMehtab2011-10-03 18:47:26
B
12
S
5
G
5
Posts: 80
Reputation: 3,572

Post » Mon Oct 03, 2011 8:14 pm

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 ?
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Tue Oct 04, 2011 8:27 am

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.
B
12
S
5
G
5
Posts: 80
Reputation: 3,572

Post » Tue Oct 04, 2011 1:46 pm

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.
B
20
S
9
G
2
Posts: 15
Reputation: 2,594

Post » Thu Oct 06, 2011 7:56 am

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
B
17
S
4
G
4
Posts: 94
Reputation: 3,058

Post » Thu Oct 06, 2011 10:36 am

thank you Spades very much. It works flawlessly. Again thanks.
B
12
S
5
G
5
Posts: 80
Reputation: 3,572

Post » Thu Oct 06, 2011 11:06 am

Your welcome =)
B
17
S
4
G
4
Posts: 94
Reputation: 3,058


Return to Construct 2 General

Who is online

Users browsing this forum: 99Instances2Go, BackendFreak, TGeorgeMihai, TheRealDannyyy and 7 guests