How do I fix this? (2D Backdrop inheriting movement, somehow)

Godot 4.3

Whenever I add a backdrop to my game, it inherits the movement, and I have zero clue why.
Heres my code for movement:
extends CharacterBody2D

@export var speed = 400

var target = position

func _input(event):
# Use is_action_pressed to only accept single taps as input instead of mouse drags.
if event.is_action_pressed(&“click”):
target = get_global_mouse_position()

func _physics_process(delta):
velocity = position.direction_to(target) * speed
# look_at(target)
if position.distance_to(target) > 10:
move_and_slide()

Could you clarify what you mean by adding a backdrop?

Are you referring to a background that moves in sync with the player, or is it the player who remains stationary while the background moves?

How are you adding this backdrop?

Hmmm… Could you give us more info about your backdrop? Are there any scripts attached to it? What kind of node is it? This script isn’t attached to the backdrop is it?

Script isn’t attached to the backdrop, it is a texturerect node. I recorded a video, but new users can’t upload.

What does the hierarchy of you nodes look like in the scene tree window? Can you post a picture? The only thing I can think of is maybe the background is a child of the CharacterBody2D?

It was a child of Character2D. But I reparented it, and it still didn’t work. I’ll post a pic,
Screenshot 2024-12-16 191811

Capture

It should look something like this picture. Everything that’s a child of characterBody2D will move with it, so if TextureRect is your backdrop, the thing you don’t want to move, then it needs to be a child of the root node and not CharacterBody2D.

Thanks so much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.