Custom Ability Issue

MatB

New member
I've started to create a 'Jetpack' Ability. I wrote 3 lines of code to add some value to the Y component of the character's position for each frame the user holds down a button. This works for a few frames but then the character starts falling even though logging shows the code is still being run (there are no other active abilities on the character). Here is the code:

public override void UpdatePosition() { var desiredMovement = m_CharacterLocomotion.LocalDesiredMovement; desiredMovement.y += m_Thrust * (m_CharacterLocomotion.TimeScale * Time.timeScale); m_CharacterLocomotion.LocalDesiredMovement = desiredMovement; }

1. Why does he start falling instead of moving upwards?
2. What is the different between LocalDesiredMovement and DesiredMovement? I cannot find any comments or documentation.

Cheers

Mat
 
1. Why does he start falling instead of moving upwards?
My guess is that it's because the gravity accumulation has gotten to be a greater value than the amount of force that you are adding. You should disable gravity for a jetpack.

2. What is the different between LocalDesiredMovement and DesiredMovement? I cannot find any comments or documentation.
LocalDesiredMovement is relative to the character's rotation, whereas DesiredMovement is relative to the world rotation.
 
I was trying something similar and used this method instead, which seems to work well. Not sure if its the best method but got it working in a script I was experimenting with.

public override void InactiveUpdate()
{
base.InactiveUpdate();

{
thrust/force code here
}
}
}
 
Last edited:
Thanks for the answers.

Justin - what is the purpose of accumulating gravity when the character is not grounded?
 
Top