Hello i have a problem with the code, but i am not sure what i did wrong

Godot Version

Godot Version 4.2.2

Question

i have a problem with the code, idk what i did wrong i fallowed the tutorial step by step but the camara doesn’t move along the x axis and when i click the “wasd”


works weird.

This screenshot does not move the camera, only rotates it.

Make sure to paste scripts instead of using screenshots. And use three ticks to format scripts like so

```
type or paste code here
```

here is the code.

@onready var neck := $neck
@onready var camara := $Camera

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

This code snippet still only rotates the camera, not moving it. Can you show how you are moving the camera? Should be related to the position property.

Make sure to use the three ticks, you can click the </> button or ctrl+e in the forum to create this for you

```
    type or paste code here
```

Results in:

    type or paste code here

i used this YouTube tutorial https://youtu.be/v4IEPi1c0eE?si=4O4QGGwnZ0Jweri4

i made a “bean” then i added a 3d node as a neck then a camara inside the bean attached to the neck and all inside a mesh.

here is the entirety of the code

type or paste code here
extends CharacterBody3D


const SPEED = 5.0
const JUMP_VELOCITY = 4.5

@onready var neck := $neck
@onready var camara := $Camera

func _unhandled_input(event: InputEvent) -> void:
	if event is InputEventMouseButton:
		Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
	elif event.is_action_pressed("ui_cancel"):
		Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
	if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
		if event is InputEventMouseMotion:
			neck.rotate_y(-event.relative.x * 0.01)
			camara.rotate_x(-event.relative.y * 0.01)
			camara.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 += get_gravity() * delta

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

	# 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 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()

Based on this

It would seem your camera is not a child of the “neck” node, so it doesn’t rotate left and right. This can be fixed by first reparenting the “Camera” node to the “neck” then updating your code path to

@onready var camara := $neck/Camera

i did as you say but it tells me this now

i just fixed it, thanks a lot for your help