Moving platform not showing as a scene

Godot Version

4.3 Manjaro

Question

What’s the problem here?

I can make a moving platform with an AnimatableBody2d very simply in my level (simple platformer to learn), and it works smoothly if I put it by hand for each platform. But as soon as I make a scene with a moving platform, it doesn’t show when I add it.

I don’t get it. :expressionless:

Edit: If I delete my AnimationPlayer node, the platform appear in my level scene, I’m more confused.

Could you share your code with us? The problem could be anything. My best guess is that you’re instantiating a scene, but you’re not actually adding it to the scene tree. But this is a wild guess because I haven’t seen your code.

Actually, there’s no code related to this.

I have a scene like this:
AnimatableBody2d
-TileMapLayer (my platform sprite is in it)
-CollisionShape2d
-AnimationPlayer (with a animation that make the platform move 300px to the right)

and my level is:
Level1
-ParallaxBG
-TileMapLayer (for the floor layer)
-Platform (the scene above)

The only thing in the code of the level is the player spawn.

Could it be that your AnimationPlayer node is the one that controls the movement of your platform? If that’s the case, placing it in another map might completely mess with the Position variables that your AnimationPlayer is using, as the Position of the platform might be different on different maps, and the AnimationPlayer always has a fixed position value set.

OK!

So I can’t make it this way then. I’ll go search about tweens as I see it a lot for things like that. Well thanks :smile:

For those in needs of a solution to moving platform with editable values.

extends AnimatableBody2D

@export var offset : Vector2
@export var timer : float

@onready var pos = $".".position

func _ready() -> void:
	start_tween()
	
func start_tween() -> void:
	var tween = create_tween().set_process_mode(Tween.TWEEN_PROCESS_PHYSICS)
	tween.set_loops().set_parallel(false)
	tween.tween_property($".", "position", pos + offset, timer)
	tween.tween_property($".", "position", pos, timer)

Love to you all :heart:

1 Like

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