I have a problem due to my Physics Body spawning at (0, 0) when I create an enemy.
My game is a sidescroller where the enemies walk from right to left and on the left side of the screen I use a raycast to check whether an enemy has reached its destination. So now I have the problem that the enemies reach their destination immediately when they spawn instead of when they reach the left side of the screen by walking there.
My inheritance hierarchy is as follows:
Scene -> AutoScrollerClass -> ScreenToBeScrolled (inherits Node) -> EnemyClass (inherits Node) -> Sprite (which has the PhysicsBody component)
I set the position and scale of the EnemyClass, but when I create the PhysicsBody and add it to the sprite (which is at this point not child of the enemy class yet) it spawns in the bottom left corner of the screen ((0,0) of the Scene I imagine) and only then gets moved to its proper location. How can I avoid this?
PS: I tried setting the position and scale of the sprite instead, but it didn’t help.