How do I move the player accordingly

0 favourites
  • 2 posts
From the Asset Store
Player's Follower
$7 USD
30% off
Players follower. use it for anything which follows the player
  • Hi Everyone,

    How do I go about having the player go up by tapping up arrow key, the player continues moving up. Then when I tap left arrow key,

    the player continues to move up until the player sees an opening to the left then the player turns.

    Thank You.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • One way of doing this might be to use the 8 direction behavior. You can have a variable set to something like 1,2,3,4 (or left, right, up, down...really whatever works), and then have events set up that simulate movement if the variable is set up a certain way.

    You will have a second variable that tracks key presses in the same way.

    For example:

    -One up pressed - set variable to "up"

    For the second part, having the player turn accordingly, I would recommend setting a sprite (a line, maybe with height of 30 and width of 1) and then have that sprite set it's angel depending on the variable, (up, down, left, right).

    Next have invisible sprites set up on openings that the player can go into, when the line sprite overlaps that invisible sprite, you set the main player movement variable to the second variable that is dynamically tracking key presses. You simply set the movement to a simulate control based on the primary variable.

    So to summarize, with this idea you'll need 2 variables, one for dynamic tracking of key presses, and an additional one that is set for actual movement control, that is set the the secondary variable when the player's "line tracker sprite" collides with the invisible "opening sprite." The line tracker sprite needs to have it's angle adjusted depending on key presses.

    I don't know whether this will work for your project because I don't really know what it is, but I'm imagining this as being something that could work for a paceman style game.

    Good luck,

    Ultra

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