Space Fighters
Last updated
Last updated
In this context, a space fighter is a ship that can move and rotate on all 3 spatial axes.
The SCK_Basics_Flying scene provides a fully functioning simple demo of the space fighter if you wish to take a look.
The SpaceFighter_Friendly and SpaceFighter_Heavy_Friendly prefabs are fully functional space fighters you can drag into your scenes or modify to create new fighters.
To create a new space fighter:
Create a new game object in the scene and call it whatever you wish
Add a Vehicle component and a Vehicle Engines 3D component
Create a new gameobject as a child of the one you created in Step 1, and call it 'Ship'
Drag your spaceship mesh from your assets folder onto the Ship object
If you just want to get started:
Drag the Player_InputSystem_SCK prefab into the scene.
Go to your new ship, open the Vehicle component, and set the Vehicle Class to SpaceFighter.
OR if you are in the process of creating your own player:
Create the player Game Agent as described in this section if you haven't already.
Add a PlayerInput_InputSystem_SpaceshipControls component somewhere in its hierarchy.
Next, open the Game Agent component on the player and set the 'starting vehicle' to your new ship.
Now when you run the scene, you can use the mouse to steer the ship, and the WASD, Spacebar and Left Control keys to move it around.
The camera may not be set up yet, if not, check out this section.
To give you more flexibility to customize the feel of your game, the Vehicle Control Animator component has been provided. Basically, this component rotates the ship slightly relative to its own root transform, according to the velocity and angular velocity of the Rigidbody, to give an extra feel of control to the player.
To set this up, add a Vehicle Control Animator component to an object that is a child of your ship's root transform (create one if it doesn't exist), and make sure the visual components such as meshes are under this child.
This child will now rotate relative to the parent transform when steering and moving the ship. The default values should work well, but you can customize the settings in the inspector to your liking.
If you haven't set up the camera yet, you may need to do so to clearly see the difference in visual effect when controlling the ship.
There are a range of different control types in space games, and the Space Combat Kit seeks to cater to them all so you can make whatever type of game you wish.
Open up the PlayerInput_InputSystem_SpaceshipControls component under the Player and take a look in the inspector. Here you will find plenty of settings to customize to control the feel of your game. Here are some key settings.
Some space games link the yaw (side to side rotation) with roll, enabling players to have full control in 3D with less input. An example of a space game with this type of control is Starlancer.
To set this up, go to the PlayerInput_InputSystem_SpaceshipControls component under the Player and set the Link Yaw And Roll checkbox to True.
Sometimes, you want the ship to maintain level in the scene, allowing the player to roll freely, but returning slowly to level position when they stop rolling.
To set this up, go to the PlayerInput_InputSystem_SpaceshipControls component under the Player and set the Auto Roll Enabled checkbox to True.
You may want the ship to rotate according to the position of the cursor on the screen, or according to the current movement of the mouse. Many games provide the option for both to the player, which you can too.
By setting the Mouse Steering Type in the inspector of the PlayerInput_InputSystem_SpaceshipControls component, you can set the mouse control to either of these types.
There are also other settings related to the mouse, such as the dead radius.
You may want the player to incrementally control the throttle with the W and S keys (or whatever input you have defined) or to have the throttle go to full when it is pressed and 0 when released.
For the former, make sure the Set Throttle checkbox is unchecked in the inspector of the PlayerInput_InputSystem_SpaceshipControls component and customize the Throttle Sensitivity value.
For the latter, make sure the Set Throttle checkbox is checked in the inspector of the PlayerInput_InputSystem_SpaceshipControls component.