When I add script my game crashes but when I take it away it runs fine

Godot Version



Hello, all the code I have for my game is 1) movement for the character , 2) a camera that follows the character to make a minimap, and 3) a bird that rotates in a circle using a Path3D. When I add code for 3) it crashes my game ill provide all the code below. Thank you for any help or any time spent trying to figure this one out.

  1. extends CharacterBody3D

var sprint_speed = 15
const SPEED = 20.0
const SPRINT_SPEED = 15.0
const JUMP_VELOCITY = 10
const JUMP_Sprint = 15
var sprinting = false

var gravity: float = ProjectSettings.get_setting(“physics/3d/default_gravity”)
@onready var neck := $Neck
@onready var camera := $Neck/Camera3D

func _unhandled_input(event: InputEvent) → void:
if event is InputEventMouseButton:
elif event.is_action_pressed(“ui_cancel”):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
if event is InputEventMouseMotion:
neck.rotate_y(-event.relative.x * 0.01)
camera.rotate_x(-event.relative.y * 0.01)
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-30), deg_to_rad(60))

func _physics_process(delta: float) → void:
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta

# Handle Jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
	velocity.y = JUMP_VELOCITY

if Input.is_action_just_pressed("ability"):
	sprinting = not sprinting

# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("left", "right", "forward", "back")
var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()

if sprinting:
	velocity.x = direction.x * SPRINT_SPEED
	velocity.z = direction.z * SPRINT_SPEED
	velocity.x = direction.x * SPEED
	velocity.z = direction.z * SPEED


extends Camera3D

@onready var player = $“…/…/…/ShadowMonsta2/CharacterBody3D”

func _ready():

func _process(_delta):
position = Vector3(player.position.x, position.y, player.position.z)

extends Path3D

func _ready() → void:
$PathFollow3D.moving = true
$PathFollow3D/Bird.move_speed = 1.0
func _physics_process(delta: float) → void:
const move_speed := 4.0
$PathFollow3D.process += move_speed * delta

Thanks again for any help!

What is that process property from $PathFollow3D?

Its supposed to make the bird move toward in the circle

I removed the process property and the code runs again, however the bird doesn’t move

I’m not used to this kind of implementantion, but I see in the docs that whatever you are trying to move in the path3d, must be a child of PathFollow3D. Then you can set progress property (not process) to a float value to make it move.

Thank you for your help, the path3d is the parent of both the pathfollow3d and bird model. I am completely new to gd script and don’t know how to make that change. If you have time do you mind helping me add those changes?

If I understand correctly you should put PathFollow3D as child of Path3D, then the object to be moved should be a child of PathFollow3D.

Check this tutorial from GDQuest:

Thank you friend, I apperciate all the help you have given me!

Hey, so that was the original tutorially that I followed and its still not working. I even tried making a new project to see if it would work isolated from the other elements and it still will not go. Do you know of any other tutorials that may provide a better results?

process? not progress?

I don’t, it seems pretty simple, I was able to make a mesh move in the PathFollow3D with no issues. What exactly happens when you add the script and tries to run the scene? Can you provide some screenshots or a short video?