Created
March 22, 2024 02:03
-
-
Save lamarmarshall/78afaaa329f7001e43be6dde715fd9b4 to your computer and use it in GitHub Desktop.
godot 4, c#, querying nodes, attributes
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 | |
{ | |
[Export] private AnimationPlayer animationPlayerNode; | |
[Export] private Sprite3D sprite3DNode; | |
private Vector2 direction = Vector2.Zero; | |
private float Speed = 10; | |
public override void _Ready() | |
{ | |
base._Ready(); | |
GD.Print("player ready"); | |
GD.Print(animationPlayerNode.Name); | |
GD.Print(sprite3DNode.Name); | |
} | |
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