0 Favourites

How do I make my player turn

  • Hi,

    My player has four direction using arrow keys. I noticed when he make a turn he curves around the turn.

    How do I eliminate that?

    Thank You.

  • Set to 4 direction, not 8 direction.

    I dunno if this is outdated or if there is a better way, but when I needed i used this tutorial: https://www.scirra.com/tutorials/791/4- ... -animation

  • I think what he want is to set angle in the property movement of the behavior to No

  • Hi,

    fernandokolbe..I look at the example and it is doing exactly what my player does.

    Gearworkdragon ..I do have it to 4-direction and set angle to No.

    The only way for my player to move properly is for him to come to a complete stop before he changes direction.

    Any other suggestions?

    Thank You.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • If that is what you want, perhaps you may wish to move the player without using behaviors. And use events instead.

    For example,

    if left key is hold : set player's x to player.x - 100*dt

    else if right key is hold : set player's x to player.x + 100*dt

    else if up key is hold : set player's y to player.y - 100*dt

    else if down key is hold : set player's y to player.y + 100*dt

    From these events, the player can only strictly move in one direction.

    Is this Yes, No, ok?

    EDIT: the above events will move the player in a very stiff fashion - not good aesthetics-wise for some games and perhaps your case.

    You can remedy this by:

    if left key is hold

    if upAccelerate <= 0

    if downAccelerate <= 0

    if rightAccelerate <= 0:

    add 100*dt to leftAccelerate

    set player's x to player.x - leftAccelerate*dt

    else

    if right key is hold :

    f upAccelerate <= 0

    if downAccelerate <= 0

    if leftAccelerate <= 0:

    add 100*dt to rightAccelerate

    set player's x to player.x + rightAccelerate*dt

    ...

    ...

    do the above for up and down direction

    ...

    ...

    every tick,

    subtract 50*dt to leftAccelerate

    subtract 50*dt to rightAccelerate

    subtract 50*dt to upAccelerate

    subtract 50*dt to downAccelerate

    Is this what you want?

  • You are right keroberos it won't be a good approach to do what I want. I think I will stay with the original suggestion. Thank you everyone.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
167 14,500
DMT2005's avatar
DMT2005
Unread hot topic
0 Favourites
[plugin] Youtube player
175 20,544
rexrainbow's avatar
rexrainbow
Unread sticky
1 Favourites
C2 Games made with CocoonIO
136 89,829
minhcuong's avatar
minhcuong