Create a new folder in assets and name it Scripts, Then click on the player in the hierachy and add component scripts, new script. and name it PlayerController, then drag and drop the script into the Scripts folder and open it up in monoDevelop. Remove the sample code. [System.Serializable] public class Boundary { public float xMin, xMax, zMin, zMax; } public class PlayerController : MonoBehaviour { public float speed; public float tilt; public Boundary boundary; void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); GetComponent<rigidbody>().velocity = movement * speed; rigidbody.position = new Vector3 ( Mathf.Clamp (rigidbody.position.x, boundary.xMin, boundary.xMax), 0.0f, Mathf.Clamp (rigidbody.position.z, boundary.zMin, boundary.zMax), ); ...
Posts
Showing posts from April, 2018
- Get link
- X
- Other Apps
Now to add a background that is not just a black void, which while space is it is not very interesting for a game world. Click on the player in the hierachy and deselect or uncheck the box next to the player in the inspector just so that it is not in the way. Then create 3D object, quad and rename it to Background, using the scene view so that it is visable and reset its transform and set its rotation X-axis to 90 this will make it visible in the game view though it is not necessary to use that view at the moment stick with scene view and remove the quads mesh collider component as it is not required. now it needs a texture, now to scale up the quad by changing the scale X-axis to 21 and Y-axis to 21 so that it fits into the game view nicely, if you were using a texture with an image resolution of 1024x2048 you would want to have the scale X be half of the Y-axis so an example would be X 15 and Y 30 to make sure the image does not become blurry. Next to add some lighting to the bac...
- Get link
- X
- Other Apps
Now for my most enjoyable part, setting up the camera. Start by selecting the Main Camera in the hierarchy and resetting its transform in the inspector, we do this because we want the view point of the player to be top-down so having it in the origin point helps this process. Then rotate the X-axis to 90 degrees, next in take the Y-axis of position and set it to 10 and this should give you a decent view. Now for the camera component, change the projection from Perspective to Orthographic and using the Game view and set the size to 10 then to make sure the ship is not in the center view of the camera change the camera position along the Z-axis to 6 and then change the Clear Flags to solid color i then set the background color to black so that there will be some cinematic arcade black borders. Next select create, light, directional light and rename it Main Light and reset its position so its at the origin point, then reset its rotation to 0 then set the X-axis to around 20. Then chang...
- Get link
- X
- Other Apps
Some of the assets i downloaded were some visual effects or VFX, i use these to make it so there is a stream of fire coming from the engine area of the player ship to make it look like its actually running which helps immersion. Do this by locating the engines_player prefab and drag it onto the Player ship in the hierachy tab so that it is added as a child game object, the prefab is made up of two particle systems.