rdInst Tutorial 41 – Proxy Vehicles

This tutorial goes through creating a static mesh for a skeletal mesh vehicle and adding proxies to ISMs of the vehicle mesh so it swaps to the vehicle when in proximity.

It also shows how the proxies and instances can be moved around without having to update anything.

The tutorial uses the Vehicle Template and the First Person template.


Step 1. Create a project and add the Vehicle and First Person templates

The first thing to do is to create a new project – add both the Vehicle template and the First Person templates to the project with the Add Content button in the Browser.

Make sure to enable the Chaos Vehicle Plugin as well.

Then create a new “Open World” level for our vehicle tests. We’re not using any spatial loading here, it’s just a nice area to place vehicles around.


Step 2. Create a StaticMesh from the vehicle SkeletalMesh

Now we need to create a StaticMesh we can use for the vehicle. Navigate to the Vehicles/SportsCar folder and open the SKM_SportsCar into the SkeletalMesh Editor. From There, click the “Make StaticMesh” button.

This will prompt you for a location and name for the new StaticMesh. Once created you can check it out in the StaticMesh Editor.

If you want to be optimal, at this point you can export the new mesh and remove all but the external triangles.

Or you can just add some LODs.

Now we need to add some collision to the StaticMesh – a simple Box Collision will suffix for the tutorial, so just add a Box Collision and leave it’s default scale to surround the vehicle.


Step 3. Create a Subclass of the SportsCar_Pawn Blueprint

Now create a subclass of the SpartsCar_Pawn Blueprint and open it in the Blueprint Editor.

Add a Collision Sphere and set the radius to 300.0. Scroll down the details panel of the Sphere Component and click the (+) for the Overlap Collision – here we will Posses the vehicle when we get close to it.

Add the code below to possess the vehicle on overlap:

And add the code below to posses the player when the “E” key is pressed:

And one last bit – add the code below to set the correct Advanced Input Mapping Context:

The “Mapping Context” for each of the nodes is the “IMC_Default” that is located in the Vehicle Folder.


Step 4. Create a new BP Spawner

The next step is to set up some of the vehicles in the level, we create a new Spawner BP subclassed from rdSpawnStuffActor.

Now add one of these to the level and set the X and Y scale to 1000.0 – move it so the volume box is centered in the level. Turn off Spatial Loading too.

Now override the “rdSpawnEvent” function and add the code below:

And add the following code to the event:

This just adds 100 vehicles randomly positioned in the volume space.


Step 5. Add Proxy Setup to the Level Blueprints BeginPlay and set the Proxy

The last step is to call the rdInst Proxy setup from the Level Blueprint. Open the Level Blueprint and add the code below to the BeginPlay event:


Step 6. Done

That’s it. Now just play the level, walk up to a car and drive. Press E to exit the car and walk around again.