Why do I get grey screen?

Godot Version

4.4.1

Question

Beginner here, very simple tree and code. Why do I get grey screen when running the game? I have the camera attached.

Scene tree:

The only code that’s in player.gd:

extends CharacterBody3D

@export var speed := 6.0
@export var jump_velocity := 4.5
@export var mouse_sensitivity := 0.002

@onready var head := $Head
@onready var camera := $Head/Camera3D

var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")

func _ready():
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _unhandled_input(event):
	if event is InputEventMouseMotion:
		# Horizontal rotation (body)
		rotate_y(-event.relative.x * mouse_sensitivity)

		# Vertical rotation (camera)
		head.rotate_x(-event.relative.y * mouse_sensitivity)
		head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(90))

func _physics_process(delta):
	# Gravity
	if not is_on_floor():
		velocity.y -= gravity * delta

	# Jump
	if Input.is_action_just_pressed("jump") and is_on_floor():
		velocity.y = jump_velocity

	# Movement input
	var input_dir = Input.get_vector(
		"move_left",
		"move_right",
		"move_forward",
		"move_backward"
	)

	var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()

	if direction:
		velocity.x = direction.x * speed
		velocity.z = direction.z * speed
	else:
		velocity.x = move_toward(velocity.x, 0, speed)
		velocity.z = move_toward(velocity.z, 0, speed)

	move_and_slide()

No errors in console.

Thanks.

You’re player camera probably just can’t see Floor for some reason. Can you post a screenshot of the scene from the editor (or the scene .tscn file)?

Hi, I didn’t have my player.gd script attached to my Player node.

You need a WorldEnviroment and some light to see anything when running the project. Check the getting started section in the documentation for more info:

1 Like