Created
March 22, 2024 00:29
-
-
Save lamarmarshall/b34ec41f984883e7c56f2a6ca2176b19 to your computer and use it in GitHub Desktop.
godot 4, c#, 2.5d player movement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Godot; | |
using System; | |
using System.Reflection; | |
public partial class Player : CharacterBody3D | |
{ | |
private Vector2 direction = Vector2.Zero; | |
private float Speed = 10; | |
public override void _PhysicsProcess(double delta) | |
{ | |
base._PhysicsProcess(delta); | |
// GD.Print("player physics process"); | |
Velocity = new(direction.X, 0, direction.Y); | |
Velocity *= 5; | |
MoveAndSlide(); | |
} | |
public override void _Input(InputEvent @event) | |
{ | |
base._Input(@event); | |
direction = Input.GetVector("MoveLeft", "MoveRight", "MoveForward", "MoveBackward"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment