Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Created March 22, 2024 00:29
Show Gist options
  • Save lamarmarshall/b34ec41f984883e7c56f2a6ca2176b19 to your computer and use it in GitHub Desktop.
Save lamarmarshall/b34ec41f984883e7c56f2a6ca2176b19 to your computer and use it in GitHub Desktop.
godot 4, c#, 2.5d player movement
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