2.4 controlling the player

This commit is contained in:
david 2025-02-02 13:54:44 +01:00
parent 680126711f
commit ceffa3f159
2 changed files with 39 additions and 13 deletions

View file

@ -3,19 +3,16 @@ using System;
public partial class Player : Node3D
{
private int counter = 0;
public override void _Ready()
{
GD.Print("Hello World!");
GD.Print("Don't Panic!");
}
public override void _Process(double delta)
{
if (Input.IsActionJustPressed("ui_accept")){
GD.Print("Spacebar is pressed");
counter += 1;
GD.Print("Counter: " + counter);
if (Input.IsActionPressed("ui_accept")){
Position += new Vector3(0, 1, 0) * (float)delta;
}
if (Input.IsActionPressed("ui_left")){
RotateZ((float)delta);
}
if (Input.IsActionPressed("ui_right")){
RotateZ(-(float)delta);
}
}
}

View file

@ -1,6 +1,35 @@
[gd_scene load_steps=2 format=3 uid="uid://cuduv6fwqtocs"]
[gd_scene load_steps=6 format=3 uid="uid://cuduv6fwqtocs"]
[ext_resource type="Script" path="res://scenes/characters/Player.cs" id="1_fr1bo"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_v656b"]
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
[sub_resource type="Sky" id="Sky_ueadq"]
sky_material = SubResource("ProceduralSkyMaterial_v656b")
[sub_resource type="Environment" id="Environment_bdllf"]
background_mode = 2
sky = SubResource("Sky_ueadq")
tonemap_mode = 2
glow_enabled = true
[sub_resource type="CylinderMesh" id="CylinderMesh_dk8lw"]
[node name="Player" type="Node3D"]
script = ExtResource("1_fr1bo")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_bdllf")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.866025, -0.433013, 0.25, 0, 0.5, 0.866025, -0.5, 0.75, -0.433013, 0, 0, 0)
shadow_enabled = true
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("CylinderMesh_dk8lw")
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5)
top_level = true