Following the player?

This forum is currently in read-only mode.
From the Asset Store
Players follower. use it for anything which follows the player
  • 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.

  • Deadeye has a good explanation of his platform AI in his 'This Cursed Rock' thread. Does that help?

  • 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.

  • I'll go try that thanks for your help.

  • 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

  • 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.

  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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

  • [quote:249h6qdd]JumpDetector: 213 overlaps "Solid"

    Zombie: 5 Value 'Action' Not equal to "Fall"

    System: Trigger once

    ZombieSet 'Action' to "Jump"

    and...

    [quote:249h6qdd]Zombie: 5 Value 'Action' Equal to "Jump"

    ZombieSet Y to Zombie 0 .Y -(Zombie 1 .Value('JumpHeight'))

    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.

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)