Enemy chase player

For questions about using Classic.

Post » Sun Jun 01, 2008 4:01 pm

I have this little guy that I want to move about until he sees the player in sight. Once he detects player he rushes over to bite him, then is delayed a second.

RIght now I was using the RTS movement and line of sight to accomplish this, which works somewhat.
CheeseHead is enemy, Spanky is Player:

CheeseHead: Has LOS to Spanky
CheeseHead: Animation "Dead" is playing
> CheeseHeadMove to Spanky

CheeseHead: Does not Have LOS to Spanky
> CheeseHeadMove to (random(100), random(100))

What I get is a wacky rotating object that follows player but always seems to have him in Line of Sight. I'm not too familiar with these behaviors, anyone have any suggestions?
B
13
S
3
G
5
Posts: 286
Reputation: 3,193

Post » Sun Jun 01, 2008 8:57 pm

Consider adding a distance argument to the event.

+Has LOS
+Distance to Spanky < ###
=then do stuff

EDIT:
As far as rotating, that behavior is avoided by changing the sprite's properties accordingly.
B
3
S
2
G
4
Posts: 310
Reputation: 2,120

Post » Mon Jun 02, 2008 2:36 pm

I dont get this LOS
It's not working for me.

I used a turret to take action based on its tracking angle.

THis worked well for me.
B
3
S
2
G
4
Posts: 322
Reputation: 2,119

Post » Mon Jun 02, 2008 2:58 pm

Just wanna throw in that the RTS movement's Move To XXX actions run a fairly CPU intensive search algorithm to generate the shortest path around obstacles. You should avoid running it every tick (add an 'every 1 second' or 'trigger once' condition for example) to avoid redundantly wasting CPU time.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests