using Godot; using System; public partial class Player : RigidBody3D { [Export(PropertyHint.Range, "750.0, 3000.0")] float thrust = 1000.0f; // The amount of thrust the players has, in newtons [Export(PropertyHint.Range, "50.0, 200.0")] float torque = 100.0f; // The amount of torque the player has, in newton meters private Vector3 ZLeft; private Vector3 ZRight; public override void _Ready() { BodyEntered += OnPlayerCollision; ZLeft = new Vector3(0, 0, torque); ZRight = new Vector3(0, 0, -torque); } public override void _Process(double delta) { float fd = (float)delta; if (Input.IsActionPressed("boost")){ ApplyCentralForce(Basis.Y * fd * thrust); } if (Input.IsActionPressed("rotate_left")){ ApplyTorque(ZLeft * fd); } if (Input.IsActionPressed("rotate_right")){ ApplyTorque(ZRight * fd); } } private void OnPlayerCollision(Node body) { if (body.GetGroups().Contains("Goal")) { GD.Print("Player landed on the landing pad"); } if (body.GetGroups().Contains("Hazard")) { GD.Print("Player crashed on the floor :("); } } }