Following the player?

For questions about using Classic.

Post » Sun Dec 07, 2008 1:21 pm

I'm wondering how I could make my enemy follow paths to follow the player and change the path according to where the player is? For example to know when to jump. It's going to be a side on view.
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Sun Dec 07, 2008 3:52 pm

Deadeye has a good explanation of his platform AI in his 'This Cursed Rock' thread. Does that help?
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Sun Dec 07, 2008 5:29 pm

One way you could do it (and the way I did it in my game) is you could make little jump triggers at the edges of platforms.

I wanted my AI to jump a little more unexpectedly in places, so I made a small sprite and stuck them here and there in key spots. Whenever the enemy passes over it, they jump no matter what.

This could be altered so that, say, if the player is on a platform above them and there's a gap in between the two platforms then when the enemy hits the jump trigger it knows to jump. But if the player is below the enemy, and the enemy is on a platform with a jump trigger at the end, it won't jump because it doesn't need to.

Since my game was small, I could get away with using jump trigger sprites like that. In a larger game where it would be a pain in the butt to place them all, and just plain inefficient at that, then you could use a detector on each of your enemies that can tell when it's at the edge of a platform (because it's no longer overlapping the platform).

As far as actual pathfinding, I have no idea. That's beyond my understanding. I've never sat down and tried to make a platform pathfinding system.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Dec 07, 2008 6:06 pm

I'll go try that thanks for your help.
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Sun Dec 07, 2008 7:19 pm

I'm having problem now because he doesn't jump at the last jump. Just floats over the gap.
http://deta12.com/downloads/construct/EnemyMovement.cap
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Sun Dec 07, 2008 8:15 pm

It looks like it's jumping fine to me. It jumps over the gap, climbs the wall, jumps over the other gap, jumps off the end of the ledge, hits the far wall and turns around, jumps off the end of the second ledge, hits the inside wall and turns around again...

and then it breaks. It looks like when it turns around at that point it moves up a few pixels for some reason, so your jump detector isn't overlapping the ground any more, so it just floats over the gap on the left side of the screen. You might just need to rework your gravity events to make sure that your enemy is always on the ground properly.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Dec 07, 2008 8:33 pm

Yea that's the bit I'm talking about. I don't see how I could fix it since my event should of made it go back down again.

Nevermind I found out what was causing it. I'm wondering how I could make the jumping more realistic though?
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Sun Dec 07, 2008 9:28 pm

Ok now it seems that the enemy goes too far into the ground and I don't know how to fix it?
http://deta12.com/downloads/construct/E ... ntv0.2.cap
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Mon Dec 08, 2008 10:03 pm

I re-did my jumping but now the enemey rockets into the sky when he jumps?
http://deta12.com/downloads/construct/E ... v0.3.3.cap
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Thu Dec 11, 2008 12:47 am

[quote:249h6qdd]JumpDetector: 213 overlaps "Solid"
Zombie: 5 Value 'Action' Not equal to "Fall"
System: Trigger once
> ZombieSet 'Action' to "Jump"[/quote:249h6qdd]

and...

[quote:249h6qdd]Zombie: 5 Value 'Action' Equal to "Jump"
> ZombieSet Y to Zombie 0 .Y -(Zombie 1 .Value('JumpHeight'))
[/quote:249h6qdd]

That's whats in your editor right?

I think the problem is that it doesn't know when to stop jumping.

if you change that 2nd part of the code to this:

[quote:249h6qdd]Zombie: 5 Value 'Action' Equal to "Jump"
> ZombieSet Y to Zombie 0 .Y -(Zombie 1 .Value('JumpHeight'))
> ZombieSet 'Action' to "" <<//I added this.
[/quote:249h6qdd]

it makes the guy jump by a sharp amount (jump height?) than fall. It isn't smooth.

the jump "function" you made is in a constant loop, always jumping.

Have you tried to make the enemy using the built-in platform behavior?
you could trigger a jump through events and disable player input.

...or work on getting the jump to work with a single button press first until you understand the way your jump code reacts to a single input (IE: 1 button press)

Hope that helped a bit. :D
B
2
S
1
G
4
Posts: 156
Reputation: 1,612

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests