State machine code have problem in delta time if using in 2d game

i trying to use state machine code in 2d game
the code really working normaly in enter and exit method
when i try make state machine on jump in 2d
but its really not working when i try to implement movement example
statemachine.rb2d.velocity = statemachine.vector2 * statemachine.movement * deltatime
in tick method the movement really slow compare to normal code

i know the problem is in tick(float delta time) but i dont know to solve it

You are changing physics stuff in a normal update loop. Physics should be updated in the fixed update. The usual state machines here don’t consider that because, well, it’s never really been necessary.

What you may need to do is add a FixedTick(float deltaTime) method to your state as well, and then call it from FixedUpdate

private void FixedUpdate()

Then do your physics things in there like you normally would

Privacy & Terms