Recently Adam Clarke, Colton Soneson, and I looked into the Unreal Engine 4 source code, in preparing to build our own engine. To conquer it's massive code base, we divided up the engine and we will each be writing a blog post on the parts of the engine we looked at.
If you are interested in reading more about the engine, you can read Adam's post, and Colton's post.
I looked at the structure of a scene, and how the levels are built.
Example object class hierarchy:
A level will contain a level blueprint and a number of actors. Each actor will contain a list of components. The base class that (almost) everything will extend is the Object class. An actor is an object that can be placed in the scene. A pawn can take input from a controller or AI. A character has implemented character movement features, and a player controller is a character with player controls implemented.
Each object in the scene most likely will have components. Actorcomponents are mostly used to manipulate data like position of the actor, score, health etc. SceneComponents include a transform which allows the component to have their own position, rotation, scale. A spring arm used for third person cameras would be an example of this. Next a PrimitiveComponent also includes an actual geometric representation, an example would be a MeshComponent. In addition to actors containing components, Components can contain components.
A scene includes a level Blueprint which can be used to script out some general behavior of a level, create the UI etc. Within the scene, there will be a number of Actors, each of which will contain a number of components. An example player (could) extend FirstPersonCharacter which extends the PlayerController class. It could then directly contain 2 components. The CapsuleComponent and the CharacterMovement component. The Capsule component would then include a Mesh and a FirstPersonCamera component. The Camera would contain a Mesh2P component which in turn would contain a Sphere component. As you can see unlike other engines like Unity, all the components of an object might not be applied directly to the base object, but can instead be applied to other components. (Diagram at bottom)
One benefit of the way a scene is structured in Unreal, is the fact that you get a Level Blueprint. This a nice feature that is missing in Unity because it allows for functionality to be added to a level without the need to create an object to house the script as a component. For example a "GameManager" script would require you to create an object which would (theoretically) have no other components except an unused transform. Although the wasted time doing transform calculations on an empty object would be negligible, it can be avoided in Unreal by using the Level Blueprint as your manager. It's nice to have that option.
Example layout of a scene with a player, light source, and sky sphere:
Bigger image since SiteBuilder doesn't let me have expandable images or change the width of a blog post:
Comentarios