Unity C# Tutorial | Simple Rocket Launch Script
Here I will show you how to make a simple rocket launch script. You can use any rocket model since this script only needs one game object. I used this Low Poly Rocket Launch Complex asset for this tutorial. You can get it here on the Unity asset store if you want to use the same asset.
speed: Initial launch speed
acceleration: acceleration value per second
maxSpeed: maximum rocket speed
transform.Translate(Vector3.up*speed*Time.deltaTime, Space.World); : Moves the transform in the direction and distance of
translation. We move the rocket in y-axis times
speed every second.
if(speed < maxSpeed) speed += acceleration * Time.deltaTime;
We want to keep the rocket keep accelerating until it reaches the
maxSpeed , so what this code does is if
speed less than
maxSpeed we add
acceleration value per second until it reaches the maximum speed;
Debug.Log(speed); with this code, we can trace the
speed in the console tab.
That's that, I told you this was a simple one!