Godot Version 4.3
Why won’t my Camera2D node make the camera follow the player for my platformer
Godot Version 4.3
Why won’t my Camera2D node make the camera follow the player for my platformer
is the camera a child of the player?
are you moving the camera with code in any way?
that is good.
did you change any settings for the camera in the inspector?
is there code doing something to the camera?
are there other cameras? could it be that this is not the default camera?
no i just added the camera node to the player instance nothing else it should work correct so why isn’t it
mmhhh.
what does the player look like?
my theory, you are somehow animating the position of a sprite and the physics object of the player is not moving.
make sure the player moves. check its position with either code, or by running the game, going to the remote
button in the tree, and selecting the player and checking position in the inspector.
i don’t think its my code see for yourself
extends CharacterBody2D
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
func _physics_process(delta: float) → void:
if not is_on_floor():
velocity += get_gravity() * delta
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
var direction := Input.get_axis("ui_left", "ui_right")
if direction:
# player is walking
animated_sprite.play("walk")
velocity.x = direction * SPEED
else:
# no input; stopping
animated_sprite.stop()
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
it has to be a setting in player or camera that is messing with position, it’s supposed to work.