How to make the play fall slowly.

TickTock

New member
I create an ability named HangAndSlide. I want the player hang on the wall and slide down slowly.

If the player is not grounded. Start the ability.
If the player is on the ground. End the ability.
When the player start to fall. Make it fall slowly.
I have tried gravity and velocity and even AddForce. They all don't work the way I want. (Velocity has no effect when I modify it. I don't know why).
Maybe I shoud use the state system?

I give the wall an Object identifier and check it with the ability.
Start Type is set to Automatic and Stop Type is set to Manual.

I have two questions.
1. How to detect the player leave the wall (by press back button when sliding down). Now I'm only check is the player grounded.
2. How to make the player slide down slowly.

I'm new to unity but NOT unfamiliar with coding. Just have no experience with code for games.
So give me some details of your framwork would be very useful. (I checked the document. Too many new concepts for me so I'm struggling.)
I'm realy trying hard. Not asking for code out of the box. Just more detail when you answer me. Thanks.

public class HangAndSlide : DetectObjectAbilityBase
{

public override bool CanStartAbility()
{
return base.CanStartAbility() && m_CharacterLocomotion.Grounded == false;
}

public override void LateUpdate()
{
if (m_CharacterLocomotion.Grounded)
{
StopAbility();
}
}

public override void UpdatePosition()
{
if (m_CharacterLocomotion.Velocity.y < 0)
{
// TODO Make the player fall slowly
}
}
}
 
Just for understanding, when the ability starts, the player is not in contact with the wall!? How does the intended behavior look like when the ability starts?
You might take a look into the slide ability, which takes also the physics material properties of the wall into account. But it requires the player to be grounded. To achieve this for a vertical wall, you can try to adjust the gravity direction, so you have some force perpendicular to the wall.
Using the state system is always a good idea as this allows to set different gravity or motor properties for your ability.
 
For some concrete code -

// TODO Make the player fall slowly

Within the ApplyPosition method you can modify the MoveDirection to make the character move more slowly. The MoveTowards ability provides a good example of this (on the XY plane).
 
Top