Spacecrafts are the heart and soul of Zendir Editor, which contains components and orbits around celestial bodies. This operator guide showcases how to create a Spacecraft Blueprint from scratch, how to add components to it and how to spawn it in a simulation.


Creating the Blueprint

The first step is to create the spacecraft blueprint. Right-click on a space on the content browser and select Blueprint Class.

image 2.png

Next, a parent class can be chosen for the blueprint. In the bottom half of the new popup, search for Spacecraft and select it. This chooses what the blueprint will inherit from and in this case, we want to inherit from the base C++ Spacecraft class. Most blueprints will have “BP_” as the prefix as that’s the standard Unreal naming convention.

image.png

NOTE

Inheriting the class from a pre-configured spacecraft (in the case of the ones with a BP_ as the prefix) will include all components that have already been attached to that spacecraft. To create a new spacecraft from scratch, the class must be the base Spacecraft one.

Give the new blueprint a name with the prefix “BP_” to follow Unreal’s naming convention and to quickly identify that this object is a Blueprint. Lastly, open it up.

image.png


Adding Components

Click on the Add button in the Components tab and then select Child Actor. This will create a child actor on the root component. The reason why we do it this way is so you can add prebuilt components we have provided and for easier reusability.

Untitled

The first component that will be added is a chassis. Once the child component is added, right-click and rename the child actor to be called Chassis.

Untitled

With the chassis object selected, navigate to the details panel on the right. Under the Child Actor Class, select the Child Actor Class dropdown and select BP_NS_Chassis_3U. This will make the child actor a copy of the selected actor class. There are several pre-configured classes for each of the components and these can be useful for changing the models per spacecraft. The pre-configured library includes pre-configured parameters, masses and meshes.

Untitled

Untitled

To add another component to the hierarchy, select the previous chassis component and add another child actor, naming it Solar Panel. This will have its transform relative to the Chassis.

Untitled

In this example, the child actor class should be a solar panel. Set the Child Actor Class to a BP_NS_SolarPanel_3U_XY class. The default transform of the spacecraft will be lying horizontally so update its transforms to have it upright and its Z-axis(blue) facing the outside of the Chassis. This can be done by modifying the Location and Rotation vectors in the transform section.

Untitled

To modify the solar panel’s variables from the blueprint, it can be found under Child Actor ComponentChild Actor TemplateZendirSolar Panel in the details panel. For a solar panel, you can modify the area, efficiency and self-shadow variables.

image.png

NOTE

Once the spacecraft has completed editing, make sure to compile and save to ensure there are no issues and the editor can use this blueprint.


Spawning a Spacecraft

Create a new level called Tutorial_Spacecaft_Guide and a new blueprint called BP_Spacecraft_Guide_Level of an actor type. We separate the logic of configuring the level into a blueprint instead of the level blueprint because it allows you to use that scenario in other levels.

image.png

Open upBP_Spacecraft_Guide_Level then go to the event graph and right-click anywhere and create a Create Object node from the event graph near the begin play node. You can easily find this function by searching Zendir. This will allow for spawning objects created for the simulation and, in this case, spacecraft.

image.png

Select BP_Spacecraft_Guide to be created in the Class dropdown. The node will now spawn the selected actor when activated.

image.png

Next, link up the BeginPlay execution pin (the white line) to the Create Object node. Now the spacecraft will be created when the this blueprint starts.

image.png

WARNING

For a spacecraft, there is no requirement to set any rotations or location parameters in the create object node as it will not affect where the spacecraft is spawned. Set an orbital element such as Classic Elements to set the position/orbit.

Finally, drag from the Return value and select Set Classic Elements to give the spacecraft a basic orbit, otherwise, the spacecraft will spawn in the centre of the Earth.

image.png

NOTE

Don’t forget to compile and save blueprints and level blueprints before using them. These will make the blueprints usable and show any errors in the blueprint.

Next, go back to the viewport tab and drag BP_Spacecraft_Guide_Level into the viewport to add it to the level. It should show in the outliner on the right.

image.png

Hit the Play button and the spacecraft will be seen in an orbit around the Earth. It’s not moving as the simulation is not being ticked.

image.png


Subclassing

It can be useful to create a spacecraft from existing ones and add components on top of them. This can save time as you won’t need to rebuild parts of the spacecraft. To do so, create a new blueprint and when selecting the parent class, select an existing blueprint such as one with a BP_NS_Spacecraft prefix. This would make the Parent class a blueprint instead of a C++ class and inherit all its components.

image.png

Open the spacecraft up and all of the components that were defined in the parent class will be inherited into the new blueprint and listed in the outliner. These can still be modified without affecting the component data in the parent class, while still being able to make variations in the class.

image.png