Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions scenes/bull.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
extends CharacterBody3D


var movement_speed: float = 2.0
var movement_target_position: Vector3 = Vector3(-3.0,0.0,2.0)

@onready var navigation_agent: NavigationAgent3D = $NavigationAgent3D

func _ready() -> void:
# These values need to be adjusted for the actor's speed
# and the navigation layout.
navigation_agent.path_desired_distance = 0.5
navigation_agent.target_desired_distance = 0.5

# Make sure to not await during _ready.
actor_setup.call_deferred()

func actor_setup() -> void:
# Wait for the first physics frame so the NavigationServer can sync.
await get_tree().physics_frame

# Now that the navigation map is no longer empty, set the movement target.
set_movement_target(movement_target_position)

func set_movement_target(movement_target: Vector3) -> void:
navigation_agent.set_target_position(movement_target)

func _physics_process(_delta: float) -> void:
if navigation_agent.is_navigation_finished():
return

var current_agent_position: Vector3 = global_position
var next_path_position: Vector3 = navigation_agent.get_next_path_position()

velocity = current_agent_position.direction_to(next_path_position) * movement_speed
move_and_slide()
1 change: 1 addition & 0 deletions scenes/bull.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://7pn2tm346eal
19 changes: 19 additions & 0 deletions scenes/bull.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[gd_scene format=3 uid="uid://c7jhd2600s4t6"]

[ext_resource type="Script" uid="uid://7pn2tm346eal" path="res://scenes/bull.gd" id="1_trfny"]

[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_euvdr"]

[sub_resource type="CylinderMesh" id="CylinderMesh_euvdr"]

[node name="Bull" type="CharacterBody3D" unique_id=1201069862]
script = ExtResource("1_trfny")

[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=158080805]
transform = Transform3D(-4.3711385e-08, -0.99999994, 0, 0.99999994, -4.3711385e-08, 0, 0, 0, 1, 0, 0, 0)
shape = SubResource("CapsuleShape3D_euvdr")

[node name="MeshInstance3D" type="MeshInstance3D" parent="CollisionShape3D" unique_id=763390464]
mesh = SubResource("CylinderMesh_euvdr")

[node name="NavigationAgent3D" type="NavigationAgent3D" parent="." unique_id=372703009]
13 changes: 13 additions & 0 deletions scenes/map.tscn

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scenes/mesh_lib_source.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://c4oco0tbnxfur"]

[ext_resource type="Texture2D" uid="uid://ifomx3yfyvk8" path="res://icon.svg" id="1_me65r"]
[ext_resource type="Texture2D" uid="uid://b5aab10h3bk6l" path="res://not_ugly.png" id="1_me65r"]

[sub_resource type="BoxMesh" id="BoxMesh_0n8u8"]

Expand Down