Train Hazard

 
TrainHazard_InGame.gif

The train hazard was something that need to be placed around the track to hinder the progression of the racers. This feature needed to be customization by the designers to allow iteration on both path and make-up of the train. The train’s path was dictated by a spline and for each train, its make-up could be customized via an array of enums for car types.

 
 
TrainHazard.png
 

 

On start up the train make-up needed to be constructed from the designer’s input array of train cars. For each element in their array of car type enums the appropriate train car actor got added to the list of train cars to update.

BlueprintUE.com is a tool for sharing, rendering and rating blueprints for Unreal Engine 4. UE4 is a game engine which use visual scripting called blueprint.

 

BlueprintUE.com is a tool for sharing, rendering and rating blueprints for Unreal Engine 4. UE4 is a game engine which use visual scripting called blueprint.

To determine the position and direction of the spawned in train car we would take steps back along the spline to approximate the curve of the spline at the spawn position and then calculate the average direction to better determine the forward direction of the car. At the same time we found the position to spawn based on the size of the last car’s size and the new car’s size.

 

Once the train was created it was a simple matter to update its position. Based on the designer’s input speed the train cars would all move forward in the direction of the spline’s tangent and then set their position back on to the spline. If given more time to work on this feature another way to more accurately update the train’s position would be to add distance along the spline, rather than the forward vector of the car, and then set the train car actor’s transform to the transform at that distance on the spline.

While working on this feature I found that by breaking more things out into functions they could be used for other things. For AI sensing of track hazards they needed to perdict the movement of the train and since everything was already broken out I only had to make a few adjustments to allow the AI sensing to get a train’s position a specified amount of time in the future.

BlueprintUE.com is a tool for sharing, rendering and rating blueprints for Unreal Engine 4. UE4 is a game engine which use visual scripting called blueprint.

HaberDashers