According to the docs, it’s not supposed to be. But while working through the Alien Attack course, when I created the player scene as a CharacterBody2D, instanced it in the game scene, and played it… the player ship immediately fell down off the screen. Could not find any setting to override this behavior (gravity scale attribute does not appear to be exposed for this object). Re-created it several times. Eventually gave up, switched to a RigidBody2D, set the gravity scale to 0, and got the desired result. I’m a bit concerned that as I work my way through the course I’m going to run into problems due to differences in inheritance. What am I doing wrong? Why was my CharacterBody2D falling? (using v4.2.1.stable.official [b09f793f5]).
The only way I was able to recreate this was by making a RigidBody as a child of a CharacterBody, which is quite different from what Kaan shows. Could you post a screenshot of your scene trees? Both the Player scene and the level scene would be helpful.
hi,
just tested with 4.2.1, with just an empty scene and a character body node. struggling to replicate.
is there a script attached to the player by any chance? if there is, does it change how it behaves if the script is removed?
just wondering, the only way i was able to have the characterbody node fall was when i added a script to the player, but instead of a blank one, i used the characterbody2D template.
but with no script attached, it should remain in position.
id be curious as well to see whats there as well, so we can try and get you back on track.
Darren
Appreciate both of you (@CoreyKnecht and @OboShape) looking at this. Your answers helped me find my mistake. Specifically, I had failed to turn off the template on the player script, and unfortunately, the template it brought in was something that brought in basic movement, which included gravity (and defeated the entire purpose of using a CharacterBody2D… at least in this instance).
Well done troubleshooting; glad you found an answer =)
Sweet, glad you found that wee gremlin in the works
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.