How do I make an enemy charge at the player?

Get help using Construct 2

Post » Sat Jan 07, 2017 11:00 pm

Message: Frolicks can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I want to make a boar enemy that 'charges' a charge attack against the player.

Image

To do this I'm adding dt to a counter called chargeTime.
Every tick, I make the boar face the player.
When chargeTime is > 3, I increase the bullet behavior on the boar from 0 to 400.

my capx:
https://drive.google.com/file/d/0B6VzyBaaZXG7ZERhbU1ZZWtpLTg/view?usp=sharing

THE ISSUE is that this only works half the time.
Sometimes the boar rushes at the player, other times it just goes forward - missing the player.
I made Bullet.angleOfMotion = Boar.angle degrees but it didn't seem to have an effect.
Why is this happening? How can I fix this?

thanks.
B
5
Posts: 4
Reputation: 233

Post » Sat Jan 07, 2017 11:26 pm

Image
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jan 08, 2017 4:33 am

Interesting! This seems to work perfectly.

Is there a logical reason why or is this method just less prone to bugs?
B
5
Posts: 4
Reputation: 233

Post » Sun Jan 08, 2017 8:39 am

Ah yes there is. Its like a car. When standing still, you can turn that steer wheel as much as you want, the car is not changing direction.
You can not change the angle of movement for a bullet that has speed zero. Since that angle was zero, the moment you give it speed, it starts from that angle.

Now, i am not sure about this statement (i should check that): the bullet gets its speed at the end of the tick, so, changing angle immediately after giving it speed is not gonna help.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: Cub3D, David181 and 18 guests