Fly your way through alien environments while battling pursuers in this 3D rail shooter.
I discuss the design process behind the standard enemy in the game.
Posted by malec2b on Feb 19th, 2013
Working in 3D for Renegade Sector Pilot has introduced a whole new set of challenges in terms of enemy design. Especially since this is a rail-shooter, meaning enemies can move fairly freely in 3d space and aren’t confined to a single plane.
I had a basic idea for a standard enemy type. It would come up from behind the player then fly around in front of him and shoot back at him, and occasionally fall back behind the player. I wanted to get that feel of jockeying for position as it flies past you and it needed to have smooth but interesting movement, meaning it couldn’t just fly in a straight line, and it it would have to gradually turn to change direction.
The easy part was making it approach from behind. I gave it a max speed slightly higher than the player’s speed, and a minimum speed slightly less than the player speed. It then had an acceleration value. If it was behind the player, it would speed up by its acceleration value, and if it were ahead of the player it would slow down. I eventually changed this point to a little ways ahead of the player, that way it would spend more time in front of the player and only occasionally fall behind the player.
I then made it change its flight angle in small circles. I had a constantly-increasing counter, then made it’s x and y angle be based on the cos and sin of the counter. So it started flying in a little spiral. The problem, of course, was that it could fly out of bounds of the stage, hitting the tree wall or the ground.
The solution I finally came up with to this was to modify the angle based on the location of the ship. The closer it is to the edge of the stage, the more it’s angle is pushed in to the middle. If the ship is in the center of the stage, it could have an angle anywhere from -10 to 10, whereas if it’s at the far right, it could have an angle of -20 to 0.