Announcement

Collapse
No announcement yet.

What should be the parent of my Components hierarchy?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    What should be the parent of my Components hierarchy?

    Apologize upfront for such a rookie question.

    Let's say I'm building a Space Shooter game, so I start off by creating the blueprint for the player (BP_Player). I want it to have 2 components: a StaticMesh and a BoxCollision. I can come up with 3 ways in which I could arrange these components:
    1. First option: I could create a Scene component (overriding the DefaultSceneComponent), then create the BoxCollider, then the StaticMesh.
    2. Second option: Maybe I could just make the BoxCollision the parent, and let StaticMesh be the child.
    3. Third option: Why not, I set the StaticMesh to be the parent, and the BoxCollision its direct child.
    I understand these are 3 different ways to achieve the same result. But maybe there is a standardised way to do it in the UE4 community, that I should be aware of. Is one way always preferred over the other? If not, when should I go for one option or the other?

    Needless to say, I will disable collision detection on the StaticMesh, since that's the job of the BoxCollision.

    Thank you!

    #2
    Nothing is set in stone as to how to construct a Blueprint so you should pick the option that makes sense to you.

    I would create a StaticMeshActor which includes a StaticMeshComponent and a Getter function for the StaticMeshComponent. Then if a collider besides the one on the mesh is required (like a trigger box) I would add that collider as a component,otherwise if the collider is determined by the shape of the mesh I would add the simple collider with the Mesh Editor tool and use the Mesh for overlap or hit events.

    Note that the transformations (Location, Rotation,Scale) affects the child collider when set to "relative" but it can be avoided if the component is set to "world".

    Comment

    Working...
    X