How do I Boss A.I.

Get help using Construct 2

Post » Tue Oct 20, 2015 1:19 am

Hello guys.
I'm doing the A.I. a boss. All he needs to do is to turn and shoot 5 in 5 seconds. Did I make. But the part that makes it turn, is not satisfactory. I had to calculate how many seconds it takes to turn each side. Is there a more precise manner to do this?

Thank you.


Capx: https://dl.dropboxusercontent.com/u/206 ... -test.capx
B
24
S
4
G
2
Posts: 96
Reputation: 2,467

Post » Tue Oct 20, 2015 4:13 am

Hey Moe,

Sometimes this kind of thing will happen (also happens with some collision events when moving fast) and the easiest way I have found to deal with it is to manually set it back to our desired angle (or position) when it overshoots.

Here is a working version of your cap: https://db.tt/fJ9rzXfm

We have added a new variable to the boss object called "SpinAngle" and each time we make it spin we just add 90 to the amount.


Just a piece of advice, although it is undoubtedly easier to make a long chain of events using the "wait" command - from my experience it ends up being very difficult to work with for a number of reasons. If you can, stick to trigger style events (that is, activate a spin function, when the spin finishes activate the shooting function etc).
ImageImage
B
121
S
23
G
7
Posts: 1,070
Reputation: 13,039

Post » Wed Oct 21, 2015 12:30 am

Hello,
Many thanks for the help and the advice. It looks pretty smart. But how would I do it here (below), for example, without the "wait x seconds"?

Image

Thanks a lot, man.
B
24
S
4
G
2
Posts: 96
Reputation: 2,467

Post » Wed Oct 21, 2015 3:25 am

No worries,

Sorry I should have been a bit more clear on what I meant about the wait command. It's not that using it is bad in itself, I just meant making long events (where you are doing lots of unrelated things) can be troublesome in that it can lead to unexpected bugs late in the project that take a lot of time to find and fix.

For instance, even with that simple function above - lets say it gets called and then a split second later your player kills the boss. Now that boss will fire his second barrage (even though he is dead) unless you get ride of the sprite immediately on death.

Here is how you would do it safely:
Image
ImageImage
B
121
S
23
G
7
Posts: 1,070
Reputation: 13,039


Return to How do I....?

Who is online

Users browsing this forum: Bootfit and 16 guests