Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | jarlowrey |
In my game there are a variety of NPCs that all derive from a custom Entity
scene. Most just move via KinematicBody2D
movement, however some will move into position and then enter into a PathFollow2D
movement. I’m having trouble creating this scene’s nodes though.
Current setup:
Node2D
- KinematicBody2D
--Sprite, CollisionPolygon, etc
Desired Setup:
Node2D
-Path2D
--PathFollow2D
--- KinematicBody2D
----Sprite, CollisionPolygon, etc
However, the nodes that do not follow a path will throw errors because No points in Curve2D
, and the ones that do follow a path cannot move the KinematicBody to a child position in the scene tree as it will break parental inheritance.
The only idea I have to solve this is to make the Path
and PathFollow
nodes Node2D
placeholders in Entity
, and change the type to Paths in the desired children. This doesn’t seem to break inheritance or cause wonky issues. But it’s pretty hacky/fragile/wasteful, is there a better way? Edit: Changing type doesn’t work, it just resets to node2D after closing the scene. No idea how to get this to work now.