Forum rules - please read before posting.

Is it possible to add deceleration when changing direction with Turn Instantly in 2D direct control?

As part of my game is in 2D mode, I am implementing the 2D player Direct Control. I found the default AC 2D controller really awesome. But as the title describe, I am trying to make the player "slide a bit" with deceleration when changing direction, especially when changing to the opposite direction.

I tried unchecking Turn instantly when under player control?, but I wish the player not to make a U-turn with an obvious radius. Is it possible to make the player takes time to make a U-turn but with zero radius?

On the other hand, may I use AC.KickStarter.player.charState to control when the deceleration comes into effect? Or are there other ways to add some script or modify Char.cs to achieve the goal?

Thank you very much for your help.

Comments

  • I'm not sure on exactly what it is you're after.  If he's to U-turn with zero-radius, should he still be animating the U-turn (ie. face down if moving right->left)?

    If it behaves the way you want (except for the U-turning) when unchecking Turn instantly when under player control?, it may be that a separate script just needs to lower his Walk speed scale right down during this time so that the U-turn becomes effectively invisible.

    You should be able to detect for this case by comparing his actual rotation with his intended rotation:

    KickStarter.player.GetTargetRotation ();
  • edited June 2018
    Actually I wish to achieve something like in this video:
    https://imgur.com/a/T190h35

    When I press the direction button opposite to the traveling direction (e.g. at about 1:00 second or at the 0:06 timestamp), the sheep would not immediately travel in the opposite direction. Instead it would decelerate in the traveling direction, then accelerate again in the opposite direction.

    I notice AC already has the deceleration when the player is stopping from walking, and has the acceleration when the player begins to walk. Can adding some code achieve the above effect? As well as when the player change traveling directions, it will experience a deceleration in the original traveling direction, and accelerate in the new direction?

    Thanks a lot.
  • I'll have to investigate.
  • Thanks in advance
  • Since the slowdown / turning etc is all integrated together, and since your example video shows the character only moving along a single line, you can achieve the same thing by simply constraining the player's "Y" position every frame:


    Attach that to your Player's root object in a script named LockPlayerY.cs.
  • edited June 2018
    Is it possible to implement such effect in a top-down game that the player can move up-down and left-right? Is there a way to make the Deceleration happens when the movement direction changes? As the Deceleration has effect when the player is stopping from movement even with Turn instantly is checked.
  • I mean if it is just up-down and left-right it is easy, but is it possible to do that for diagonal / arbitrary motion? I tried setting the player.charState = CharState.Decelerate; but it seems to have no effect. Is it because arrow key still dominates and override the Decelerate state?
  • Good news, I done it by comparing the player's velocity vector with the input axes vector. If they are in the opposite direction I set the Movement Method to None, and also set the charState to Decelerate. It works as I desire :)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.