I've implemented a new ability for Climbing Ladder.
I have some problems with managing the character's movement during the ascent and descent of the staircase and when I have to finish the animation execution.
Following the documentation this is my code:
If I press the up / down keys the animations starts correctly and the effects seems to be the one wanted but in reality even without pressing the keys the character continues to go up (look the end of video). Now the direction is always the one in upward direction also with the down button.
1) I would like to understand how to intercept the up / down direction to change the function like this to solve the problem:
m_DirectionUpDown = ..... (-1 / +1)
m_CharacterLocomotion.MoveDirection = new Vector3(0, m_SpeedClimbing * m_DirectionUpDown, 0);
2) how can I stop the animation and the climb when the key up/down is not press?
3) how can I interrupt the ability when the collider ends?
I have some problems with managing the character's movement during the ascent and descent of the staircase and when I have to finish the animation execution.
Following the documentation this is my code:
C#:
[SerializeField] protected float m_MaxRotationAngle = 0f;
[SerializeField] protected float m_SpeedClimbing = 0.05f;
public override void ApplyRotation()
{
var angle = Quaternion.Angle(Quaternion.identity, m_CharacterLocomotion.Torque);
if (angle > m_MaxRotationAngle)
{
m_CharacterLocomotion.Torque = Quaternion.Slerp(Quaternion.identity, m_CharacterLocomotion.Torque, 0);
}
}
public override void ApplyPosition()
{
m_CharacterLocomotion.MoveDirection = new Vector3(0, m_SpeedClimbing, 0);
}
If I press the up / down keys the animations starts correctly and the effects seems to be the one wanted but in reality even without pressing the keys the character continues to go up (look the end of video). Now the direction is always the one in upward direction also with the down button.
1) I would like to understand how to intercept the up / down direction to change the function like this to solve the problem:
m_DirectionUpDown = ..... (-1 / +1)
m_CharacterLocomotion.MoveDirection = new Vector3(0, m_SpeedClimbing * m_DirectionUpDown, 0);
2) how can I stop the animation and the climb when the key up/down is not press?
3) how can I interrupt the ability when the collider ends?