Here is my project http://47.100.74.119/projects/threejs/
(may take a little time because of low bandwidth)
I try to create an animationStatemachine for the player animations (like we did in Unreal or Unity)
for now on, move animation is fine , but when I try to make ‘jump’ animation transfer logic I noticed that the player y-axis velocity (playerVelocity.y) is floting with deltatime which I can’t simply use it for ‘falling’ animation (I was trying to made a logic 'if y-axis velocity greater then -0.2 then play falling animation).
now becuase y-axis velocity can’t use on this, I’m using ‘playerOnFloor’ for it, but this cuase other problom when my character walk down the stairs, the condetion ‘playerOnFloor’ will keeping trager in true and false makes my character very oddity.
Character controllers are hard.
I think, sometimes this can be solved by checking casting a ray downwards, and checking if it hits the floor… so playerOnFloor will use that instead of the collision itself…
Or… put use a timer of some kind, and make playerOnFloor stay true for a minimum amount of time…
let now = performance.now();
if(playerOnFloor)
lastFloorTime = now;
if(lastFloorTime > (now-250)) // wasOnFloor stays true for 1/4th second after lastFloorTime
wasOnFloor=true;
else wasOnFloor=false;
if( ! wasOnFloor ) // do the jump
It seems you’re encountering difficulties with the playerOnFloor
condition and the playerVelocity.y
value when trying to implement the jump animation. The playerOnFloor
condition might be triggering incorrectly when your character walks down stairs, and the playerVelocity.y
value might not be suitable for determining the falling animation.