private void ApplyLadderMovement(float physicsDelta) { if (ladder != null) { targetVelocity = Vector3.Zero; direction = SignalUtil.Emit <Vector3>(this, SignalKey.GET_DIRECTION); headBasis = head.GlobalTransform.basis; targetVelocity += direction.x * headBasis.x; targetVelocity += direction.z * headBasis.z; targetVelocity = targetVelocity.Normalized(); targetVelocity.y = GetFixedMovementDirection(); targetVelocity *= ladderSpeed; if (!kinematicBody.IsOnFloor()) { targetVelocity.x = 0f; EmitSignal(SignalKey.SET_MOVE_AND_SLIDE_WITH_SNAP_VELOCITY, Vector3.Zero); } velocity = SignalUtil.Emit <Vector3>(this, SignalKey.GET_MOVE_AND_SLIDE_VELOCITY); velocity = velocity.LinearInterpolate(targetVelocity, physicsDelta * GetAcceleration()); EmitSignal(SignalKey.SET_MOVE_AND_SLIDE_VELOCITY, velocity); EmitSignal(SignalKey.SET_GRAVITY_ENABLED, false); } else { EmitSignal(SignalKey.SET_GRAVITY_ENABLED, true); } }
private void ApplyJump() { if (kinematicBody.IsOnFloor() && Input.IsActionJustPressed(PlayerInput.P1_JUMP)) { velocity = SignalUtil.Emit <Vector3>(this, SignalKey.GET_MOVE_AND_SLIDE_VELOCITY); velocity.y += jumpSpeed; EmitSignal(SignalKey.SET_MOVE_AND_SLIDE_VELOCITY, velocity); } }
private void ApplyMovement(float delta) { targetVelocity = Vector3.Zero; direction = SignalUtil.Emit <Vector3>(this, SignalKey.GET_DIRECTION). Rotated(Vector3.Up, head.Rotation.y); if (direction.x != 0f && direction.z != 0f) { targetVelocity = direction * GetMoveSpeed() * diagonalMoveFactor; } else { targetVelocity = direction * GetMoveSpeed(); } velocity = SignalUtil.Emit <Vector3>(this, SignalKey.GET_MOVE_AND_SLIDE_WITH_SNAP_VELOCITY); velocity.y = 0; velocity = velocity.LinearInterpolate(targetVelocity, delta * GetAcceleration()); velocity.y = 0; EmitSignal(SignalKey.SET_MOVE_AND_SLIDE_WITH_SNAP_VELOCITY, velocity); }