Enemy follow player without rotating?

Get help using Construct 2

Post » Tue Feb 12, 2013 9:46 am

I'm creating a top-down rpg, and I'm trying to figure out how to do a couple things with the enemy:

1. I'd like the enemy when > X amount of pixels away from the player to sine randomly horizontally AND vertically (similar to the old final fantasy npcs)

2. Once I'm close enough to the enemy (< X amount of pixels), I'd like the enemy to follow the player WITHOUT rotating, but still changing the animation based on angle (ie. if I'm below the enemy, the enemy is playing a facing down animation; if I am to the right of the enemy, the enemy is playing the facing right animation)

Can anyone please help with this? I can only seem to make the enemy follow me while rotating which looks ridiculous in an rpg :).

Thanks in advance!
Steve
B
22
S
3
Posts: 451
Reputation: 2,135

Post » Tue Feb 12, 2013 11:08 am


Create a enemy_node sprite - set it to hidden.

Make it follow the player.

Pin the enemy monster sprite to it.. the pin behaviour can be set to position only..

hope that helps :)
B
6
G
2
Posts: 37
Reputation: 1,499

Post » Tue Feb 12, 2013 7:07 pm

Hey Matt,

Thanks for the response. I figured out another way to do - basically:

System Event (if Distance(Player.X,Player.Y,BadGuy.X,BadGuy.Y) < 900
Move (2) Pixels at angle Angle(BadGuy.X, BadGuy.Y, Player.X, Player.Y).

Now my only issue is making it so if the badguy is moving between x angle and x angle, play "X" animation. But for some reason it doesn't seem to work.

Anyone know how to change the enemy's animation based on it's movement?

Thanks!
Steve
B
22
S
3
Posts: 451
Reputation: 2,135

Post » Wed Feb 13, 2013 5:51 am

Sorry to bump, but has anyone been able to figure this out? I can't find an appropriate answer anywhere in the forums.

Thanks,
Steve
B
22
S
3
Posts: 451
Reputation: 2,135

Post » Wed Feb 13, 2013 6:56 am

Would something like this work for you:

for each badguy
badguy.angle > x
badguy.angle < y
.. set animation to z

Repeat for each animation.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Feb 13, 2013 7:27 am

Hey Vee,

Could you maybe expand a little more on what you mean?

Based on what you said, I did something similar which works, just not as well as I'd like it to:


IF
System Event (compare variables) - Player.X < BadGuy.X
System Event (compare variables) - Player.Y < BadGuy.Y

THEN
Set BadGuy animation to "WalkLeft"

Basically saying if the character is to the left of the BadGuy and above the BadGuy, the animation will play WalkLeft. While this kind of works, the animations change on diagonal increments.

Let me know if you meant something else?

Thanks,
Steve
B
22
S
3
Posts: 451
Reputation: 2,135

Post » Wed Feb 13, 2013 8:07 am

Thats a bit different principle, my idea is to just set the animation based on badguys angle. Posting a .capx of your problem would help a lot :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Feb 13, 2013 8:20 am

http://stevemazzaro.com/CAPXTest.zip

Here's the capx. The section you're looking at is in the Enemies group folder (1st couple of events)

Thanks!

Steveome6a17172013-02-13 08:25:09
B
22
S
3
Posts: 451
Reputation: 2,135

Post » Wed Feb 13, 2013 8:25 am

Link didn't work for me. :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Feb 13, 2013 8:29 am

http://stevemazzaro.com/CAPXTest.zip

Sorry try this.
B
22
S
3
Posts: 451
Reputation: 2,135

Next

Return to How do I....?

Who is online

Users browsing this forum: studio UNNAMED and 3 guests