Components Within UE4
Within the Unreal Engine, components work the same as other languages where a component is useful for sharing common behaviors between Objects or Actors. Components within the Unreal Engine are the only way to render meshes, implement collision between objects, or even play audio. Everything that a player can see or interact with while in the game is some type of Component. An actor essentially is a container that holds these different components. These components are what control the actor or how the actor behaves. The main types of Components that can be used within the Unreal Engine are a “UActorComponent”. This is the base Component, they are linked with a specific Actor but they don’t exist at any specific place within the world. It is mostly used for AI or interpreting player input. There are also “USceneComponent” which is an ActorComponent that has a transform. When we say “transform” in the Unreal Engine we mean that it has a position in the world, a defined location, rotation and scale, this is the root for the Actor. The another component is the “UPrimitiveComponent” , this is what holds all the physics and collision settings for the Actors.
Now that we know the different components we need to use them within our Unreal projects. First, for an Actor Component to be able to do anything within our world we need to register it. This happens automatically for Components of an Actor once the Actor “spawns” in. There is also a manual registration that can be done. In the registering process the Unreal Engine associates the Component with the scene and makes it available for per-frame updates. Actor Components can update each frame with the “TickComponent”. This “TickComponent” function allows Components to run code on every single frame. By default Actor Components don’t update on their own. For them to update on every frame you have to enable the ticking setting. I mentioned earlier about physics, there is a Physics state within the Unreal Engine. By default Actor Components or Scene Components do not have any physics states. That is where the Primitive Components come into play. Basically a Primitive Component is just a Scene Component that contains or can generate some kind of geometry to the Actor that can be used for collision data. There are different types of these that can be used for collision detection, some that are rendered and some that still provide the collision detection but are not rendered at all.
To add Components within the Unreal Engine you would simply just select the type of Component which you would like to add from the dropdown list that is provided by UE4
UE4 will prompt you to name your newly added Component after you have selected one. The “Transform” of the Component that you just added will have the default location of that instance. If you select your Component and drag it into your world when adding it then the Transform will be set to where the Component is placed. You can always manually change the Transform for your component or when dragging it and moving it around the world the Transform will automatically update according to where the Component is placed.
Within this area as well you can change the name of the instance within in the “Variable Name” area. Components within the Unreal Engine are what give your Actors behavior and functionality, as well as giving them visual attributes if the Actor is rendered. Components are very useful and can do so much within the Unreal Engine that without understanding fully the abilities and concepts that are used when creating and working with them, you won’t be able to build a functioning project within Unreal because Components are what make up almost every aspect of your game.