using Godot; namespace Babushka.scripts.CSharp.Common; public partial class Player3D : CharacterBody3D { [Export] private float _speed = 1.0f; [Export] private Camera3D _camera; public override void _PhysicsProcess(double delta) { if (!IsOnFloor()) Velocity += Vector3.Down * (float) delta; var inputDir = Input.GetVector("move_left", "move_right", "move_up", "move_down"); inputDir = inputDir.Rotated(-_camera.GlobalRotation.Y); var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized(); if (direction != Vector3.Zero) { Velocity = new Vector3(direction.X * _speed, Velocity.Y, direction.Z * _speed * (float) delta * Scale.X); } else { Velocity = Velocity.MoveToward(new Vector3(0, 0, 0), _speed); } MoveAndSlide(); } }