Does anyone know why the bird is suddenly jerking down sometimes before I officially add the code for the shield going to the player’s location?
I didn’t change the code at all from before I changed the bird to a seperate scene, only the way the object is in the hiearchy, so it doesn’t make sense for the object to move differently if I didn’t change the code that moves it.
This is incorrect. the PackedScene only has to exist in the files for it to be instantiatable. Not the scene tree. When using .instantiate()
you are creating a new object that is then added to the scene tree with .add_child()
Oh, that makes more sense - I will try it and see if it works, hopefully it should because you have a lot more expertise than me.
Yes indeed it does, but it doesn’t answer why the bird jerks almost every time I jump when it didn’t before.
I am not sure, is it a child of something other than the root node? maybe the rabbit?
No, it is a child of the root node directly, just like SnailPowerup before I deleted it.
The latest upload is at the very top, per usual.
Your player is offset
This means it thinks it’s at (0,0) but visually it is in the corner. When jumping you run the clamp function, this combination is what creates the visual jerk.
I recommend making all of your scenes centered at the (0,0) point where the green and red lines intersect.
Okay, thank you so much! Now that makes sense.
Unfortunately, even though I instantiated it in the gamenode script the same way as for the snail powerup and mob objects, which appear fine, the player never appears period.
What else am I missing?
Demonstration attached to the top post per usual.
That new_game()
function never runs, and that’s a good thing. Just instantiate the player as you did before, remove player_scene: PackedScene
from the script you do not need the script to instantiate the player, just do it from the editor.
This line on 7 is an error, you can remove it too.
@export var mob_scene: PackedScene
@export var snailpowerup_scene: PackedScene
#@export var player_scene: PackedScene << remove this
@export var shieldpowerup_scene: PackedScene
#@export var Player: Player << remove this
@onready var player: Player = $Player
Okay. Does the player appear after you fix those details?
Yes, I place the player in the editor
Okay. Very good.
Okay, now the player works correctly but now disappears randomly when I don’t actually hit a mob, as the latest attachment at the top demonstrates.
What do you think I might be doing wrong?
Their collision shape is way off, and their visibility layer was set to “2” but their collision layer should be “2”
Oh, now that makes a lot of sense why it’s being weird.
Now we’re back to the same weirdness about it not disappearing when it hits a mob after fixing the collision circle to fit on the object, even though the Player.gd script is attached correctly and the area_entered signal is correctly connecting the Player to itself.
Works for me, are you sure the collision layer is set correctly? And the collision mask? is the collision shape near the bird?
You have the rabbit there for reference it’s using the same script, so it needs the same properties.