Presentation is loading. Please wait.

Presentation is loading. Please wait.

Child Actor Component Templates

Similar presentations


Presentation on theme: "Child Actor Component Templates"— Presentation transcript:

1 Child Actor Component Templates
Or: How I Learned to Stop Worrying and Love Child Actor Components

2 Child Actor Components: What and Why?
One limitation of the Unreal Engine Framework is that one Actor cannot fully contain another Actor. That’s what Components are for! This limitation also extends to Blueprint. Child Actor Components help us work around that limitation by making one Blueprint a Child Actor of another.

3 How to Use CACs Add a Child Actor Component to your Blueprint.
Set the Child Actor Class property to your desired class. Usually another Blueprint Pro Tip: dragging a Blueprint into the Components panel of an existing Blueprint will automatically create a properly set up CAC!

4 CACs: Under the Hood Child Actor Components do not actually change an Actor into a Component! Remember previous limitation: Actors cannot contain other Actors. Instead, CACs create a spawned version in the Constructor (like the Construction Script). If spawned, CACs spawn immediately after the parent Actors If placed, Unreal keeps the reference so we don’t have to spawn at Begin Play The CAC itself is an attachment point. Child gets parented to this. You can use the CAC as a transform to move the Child Actor around. General rule: you generally want to avoid using too many Components on a single Blueprint. How many is too many? It depends… Remember: smart developers use all things in moderation. :)

5 Why Would You Use Child Actor Components?
Can be a good way to “compartmentalize” construction of a Blueprint. Can be used to distribute workload across multiple artists/devs. Kit bashing as a development approach. Take one pre-built thing, bolt it onto another! If the part (or Component) you’re building needs its own Components. If you like the tradeoff of more project assets in return for more focused functionality on individual parts, CACs might be for you.

6 Editing CACs One of the major limitations of Child Actor Components is that, historically, they are very difficult to edit or control within Blueprint. Traditionally there was no path to update the variables of a Child Actor. If your Child Actor is anything more than a self-contained black box, then you need to treat it like a completely separate Blueprint and use BP communication to make changes. This can be very tedious.

7 Child Actor Templates (4.14+)
Child Actor Templates bring us one step closer to having Blueprint-within-Blueprint interaction. As of UE4.14, when you add a Child Actor Component, you now get a Child Actor Template in the Details Panel. This provides access to any Editable variables that have been set up on the Child Actor. If any of those variables drive parts of the Construction Script, the CAC will update in real time.

8 And now, a demonstration!

9 Caveats At this time, you do not have per-instance controls.
This means that you can only make changes within the parent Actor’s Blueprint Editor. You will be editing the default values for the class. Maybe someday… Can’t modify the Components of the Child Actor Class But you can build editability into the Child Actor’s Construction Script and drive through variables. You cannot convert a Child Actor Component instance into its own Blueprint.

10 Bonus: Child Actor Component vs. Blueprint Components
Why would you use CACs instead of BP Components? Just as Actors cannot contain other Actors, Components cannot contain Components This means that BP Components cannot also contain Static Mesh Components, etc. If you need something that is a fully realized accessory (Mesh, FX, behavior, etc.) then you should be using CACs. If you only need data or specific behavior without additional parts, then you should use BP Components. If that data or behavior requires local transform relative to the owning actor, use Scene Component. If local transform is irrelevant, just use an Actor Component.

11 Bonus Bonus: Getting a Reference
While Child Actor Templates give great access to exposed variables, you may need to update the Child Actor in some way at runtime. You can get a reference from the Get Child Actor function, then cast to the appropriate class!

12 Bonus Bonus Bonus: C++ Version?
If you want to see how Child Actor Components work in C++ take a look at our Tanks vs. Zombies stream! The turret on the tank is a Child Actor Component, done in C++

13 Thank you!


Download ppt "Child Actor Component Templates"

Similar presentations


Ads by Google