Restricting the player movement

0 favourites
  • 11 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • How do I restrict the player movement? I need the player only move along a track (like a rail) with multiple junctions. Any help? Thank you.

  • I would suggest making your own movement events.

    eg.

    While Left Arrow is down

    • >Set X to Object.X-2

    While Right Arrow is down

    • >Set X to Object.X+2
  • Are you thinking something top down like a train track? or a left and right?

    Either way the Bullet behaviour is a awesome for straigt forward limited movement. I have a top down shooter where I ended up using bullet for movement instead of 8way. The reason being was that i am planning to use a analog stick.

    BULLET is awesome. Just have it that at the junction, use a collision/ocerlapping to change the direction of the bullet object.

    if you do a picture or share a sample of your idea we can help a lot more :)

  • Hy guys

    Thanks for the reply.

    I intend to restrict a player movement only, forcing that he can only move along a narrow path (like a rail or track) with multiple branches (like a maze). This way, he can go back and forth from any direction, including diagonally if necessary. A simple example attached

    Thanks

    <img src="http://dl.dropbox.com/u/72651057/track.gif" border="0" />

  • How about something like:

    if NOT player.overlapping.path

    stop movement

    snap player to path

    if player.overlapping.path

    enable movement

    You get the general idea :)

  • Hi vee41

    This restriction should be mandatory and not optional. As I understand your suggestion, it seems that the player does need to try to follow the trail. Is it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is what I had in mind: dl.dropbox.com/u/19921470/rails_example.capx

    It 'sort of' works, what it needs to make it usable is proper turns and stuff. It's quite bad example really, just something I threw together to show what I meant :)

  • Thanks for the example,

    I get it, but it seems not work in diagonally. Is this the best solution?

  • I did some experiments with the 8-directions behavior and works too (I wonder why use the bullet instead of 8-directions). The problem is that the player is not stuck to the rail and does not change direction smoothly in perpendicular movements. If I move the playe horizontally and pressed the UP / DOWN in the middle of the line, the sprite loses the path reference and doesn't move anymore.

    Sample: http://dl.dropbox.com/u/72651057/rail_test.capx

    Please some more ideas and suggestions.

    Thanks

  • Have you tried using solid invisible blocks to create a invisible barrier around each track? You can then set up custom movement or 8 directional, or even bullet. Car movement might be what you want for a train game though

    I did some experiments with the 8-directions behavior and works too (I wonder why use the bullet instead of 8-directions). The problem is that the player is not stuck to the rail and does not change direction smoothly in perpendicular movements. If I move the playe horizontally and pressed the UP / DOWN in the middle of the line, the sprite loses the path reference and doesn't move anymore.

    Sample: dl.dropbox.com/u/72651057/rail_test.capx

    Please some more ideas and suggestions.

    Thanks

  • Retro - Using invisible barriers gives me a problem (I'm trying to work out the same thing like the OP).

    If I have a gap between walls/invisible barriers, and if my sprite is the same width as the gap, then the sprite gets stuck along the path! It wont move at all, unless I set the wall to Not Solid.

    Of course I could make the sprite smaller, but then wouldnt I get jittery movement if the player presses up/or down?

    Any solutions to the sticky wall phenomenon?

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