Enemy Movement Weirdness

Just started using Construct 2? Post your questions here

Post » Tue Nov 08, 2016 4:43 am

Hi, I've got a pretty simple question pertaining to some odd behavior by the enemies I've created.

Image

It has two LOS behaviors: A big one that sets it active (Enemy01los01), and a smaller one that tells it to attack (Enemy01los02. When the player leaves the smaller one, it's supposed to set the enemy back to the walking animation, and it only sort of does. The enemy gets stuck at the beginning of the walk animation for a few seconds before it fixes itself, and I can't figure out why.

Image

Here is the entirety of the enemy's code. Anything jump out that could be the culprit?
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Tue Nov 08, 2016 6:21 am

Easy.
This all things hapend every tick. So when your player is close to enemy it wait random time then attack. But it hapend every time so for example 60 times per second. So script will do this 60 times. Script wait random time 60 times per second and then attack 60 time per second.

You must add boolean isattacking. When is attacking is true dont attack. When you attack before wait set isattacking to true. And after animation attack end set isattacking to false. At start isattacking is false.
B
22
S
3
Posts: 74
Reputation: 1,515

Post » Tue Nov 08, 2016 6:34 am

Thank you, that fixed the problem! I figured it'd be a pretty simple solution. I sometimes forget that actions execute every tick unless you manually tell them not to. :)
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Tue Nov 08, 2016 7:11 am

edit: moved to its own thread as it is a different question entirely
B
18
S
9
Posts: 103
Reputation: 1,817


Return to Beginner's Questions

Who is online

Users browsing this forum: Exabot [Bot] and 1 guest