Hi i have problem because when my player character jump on platform while moving my character falling (image below)
Here is moving script
sprint = false;
iswalk = false;
Vector3 direction = new Vector3();
direction.x = 0;
direction.z = 0;
var aim = camera.GlobalTransform.basis;
if (Input.IsActionPressed("ui_left"))
{
direction -= aim.x;
//Rotation
GetNode<Spatial>("Armature").Rotation = new Vector3(0f, Mathf.LerpAngle(GetNode<Spatial>("Armature").Rotation.y, Mathf.Atan2(velocity.x, velocity.z), delta * 7f), 0f);
//Animation
iswalk = true;
}
if (Input.IsActionPressed("ui_right"))
{
direction += aim.x;
//Rotation
GetNode<Spatial>("Armature").Rotation = new Vector3(0f, Mathf.LerpAngle(GetNode<Spatial>("Armature").Rotation.y, Mathf.Atan2(velocity.x, velocity.z), delta * 7f), 0f);
//Animation
iswalk = true;
}
if (Input.IsActionPressed("ui_up"))
{
direction -= aim.z;
//Rotation
GetNode<Spatial>("Armature").Rotation = new Vector3(0f, Mathf.LerpAngle(GetNode<Spatial>("Armature").Rotation.y, Mathf.Atan2(velocity.x, velocity.z), delta * 7f), 0f);
//Animation
iswalk = true;
}
if (Input.IsActionPressed("ui_down"))
{
direction += aim.z;
//Rotation
GetNode<Spatial>("Armature").Rotation = new Vector3(0f, Mathf.LerpAngle(GetNode<Spatial>("Armature").Rotation.y, Mathf.Atan2(velocity.x, velocity.z), delta * 7f), 0f);
//Animation
iswalk = true;
}
if (Input.IsActionPressed("sprint"))
{
sprint = true;
}
//Animation
if (iswalk)
{
if (sprint)
{
move_animation = animator.SetValue(delta, ref move_animation, 1f);
animationTree.Set("parameters/walk/blend_amount", move_animation);
}
else
{
move_animation = animator.SetValue(delta, ref move_animation, -1f);
animationTree.Set("parameters/walk/blend_amount", move_animation);
}
}
else
{
move_animation = animator.SetValue(delta, ref move_animation, 0f);
animationTree.Set("parameters/walk/blend_amount", move_animation);
}
// End Animation
//Jump Animation
if (Input.IsActionJustPressed("jump") && IsOnFloor())
{
velocity.y += 3f;
}
if (!IsOnFloor())
{
jump_animation = animator.SetValue(delta, ref jump_animation, 1f);
animationTree.Set("parameters/jump/blend_amount", jump_animation);
}
else
{
jump_animation = animator.SetValue(delta, ref jump_animation, 0f);
animationTree.Set("parameters/jump/blend_amount", jump_animation);
}
//End Animation
direction = direction.Normalized();
velocity.y -= gravity * delta;
var temp_velocity = velocity;
temp_velocity.y = 0;
Vector3 target;
if (sprint)
{
if (IsOnFloor())
{
target = direction * 6f;
}
else
{
target = direction * 4f;
}
}
else
{
target = direction * 2f;
}
int acceleration = 0;
if (direction.Dot(temp_velocity) > 0)
{
acceleration = 2;
}
else
{
acceleration = 6;
}
temp_velocity = velocity.LinearInterpolate(target, 4 * delta);
velocity.x = temp_velocity.x;
velocity.z = temp_velocity.z;
velocity = MoveAndSlide(velocity + GetFloorVelocity(), Vector3.Up);
Here is my scene tree

Here is how player react while platform moving
