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.
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
}
}
}