Пример #1
0
        // TODO: hold jump higher
        public override void _PhysicsProcess(float delta)
        {
            if (Player.ActionLock.IsLocked)
            {
                return;
            }
            base._PhysicsProcess(delta);
            Coyote -= delta;
            var onFloor = Player.IsOnFloor();

            if (onFloor)
            {
                Coyote = CoyoteTime;
            }
            if (!Input.IsActionJustPressed("ui_jump") || Player.ActionLock.IsLocked)
            {
                return;
            }
            var canJump = onFloor || Coyote > 0;

            if (!canJump)
            {
                return;
            }
            Player.Velocity.y = -JumpHeight;
            GetNode <AudioStreamPlayer2D>("AudioStreamPlayer2D").Play();
            if (Player.IsOnFloor())
            {
                ParticlesEmit.Emit(0.1f);
            }
        }
Пример #2
0
Файл: Run.cs Проект: wsenh/ld47
        public override void _PhysicsProcess(float delta)
        {
            if (Player.ActionLock.IsLocked)
            {
                return;
            }
            base._PhysicsProcess(delta);
            var direction = Input.GetActionStrength("ui_right") - Input.GetActionStrength("ui_left");

            Player.Velocity.x = Mathf.Abs(direction) > 0
                ? Mathf.Lerp(Player.Velocity.x, direction * Speed, Acceleration)
                : Mathf.Lerp(Player.Velocity.x, 0, Friction);
            if (direction == 0)
            {
                return;
            }
            if (Player.IsOnFloor())
            {
                ParticlesEmit.Emit(0.1f);
            }
        }