Camera Path On Rails Shoot Tutorial


This tutorial will show you how to make an on rails style shooter with Camera Path Animator 3.0. There are some bits of code to go through but it’s all quite easy, I promise!
You’ll find an example scene in this asset and you can play it here.


First you’re going to need a level of some kind that we’re going to set our game in. I’ve used part of the Unity Tech demo Angry Bots which is perfect for our needs.


Secondly we’re going to add a Camera Path Animator to the scene. Click on GameObject > Create New Camera Path. It will insert one right in there!


We need to define a route through our level. I’m going to leave the layout up to you but to use Camera Path Animator do the following. Lay out the points you have to start the path.

Then in Path Point mode pathpoints, click on the Add Points to End of Path to add more to the end. Keep creating and placing until you have all the points where you want them.


Next, it’s best to modify the control points in the Control Point mode controlpoints so the curve goes where you want it to go. Just select and transform the points like you normally would.


Make sure you’re in the Custom orientation mode in the animator.


The select the Orientation mode orientation in Camera Path and rotate point to face where you want them to. Feel free to enable Show Orientation Indicators and use the Animator preview window and slider to understand how Camera Path Animator is interpolating your path and your camera is facing the right direction.


Next, create an empty game object and name it On Rails Manager. Add the TargetManager.cs component to it. you might want to assign an icon to this as it’s an empty game object. And finally assign the Camera Path you’re using to it’s Animator field.


Next grab the Target prefab from the examples. The root GameObject contains the Target.cs component, a Box Collider and a child GameObject containing the graphic for the target.


The Target.cs component allows external scripts to make it present the target and detects a mouse click to hide it once again. Create a few targets in some initial scene where the first wave of enemies will appear.


Then link up the Targets with the TargetManager by adding them to the Scene1Targets array. In  the code, on line 60, we can see that the Manager is waiting for an event from the Animator called “Scene1”. When this event is broadcast, it then tells every target registered in the Scene1Targets array to show. We also see an event called “Scene1End” which will tell all those targets to hide.


Se we need to create an event to start “Scene1”. In the Camera Path component select the Events mode events and click on Add Points. In the scene view, you can click place an event to signal the start of this “Scene1”. In Camera Path component, click the Done button, change the mode to Broadcast if it’s not already and rename the event we just placed as “Scene1”. You can do the same thing for the end of scene event naming it “Scene1End”. take extra care naming your events, typos will mean it won’t work.


Now you should be able to play the game and at the event point, your targets will all appear. You’ve got the basics down for an On Rails Shooter!

Comments are closed.