![]() ![]() Press play and test it out! Creating the UIĪlthough we don’t have the game’s systems running yet, let’s begin by creating the UI. We can select the camera anchor and fill in the properties: Vector3 dir = forward * moveZ + right * moveX Vector3 right = įloat moveX = Input.GetAxisRaw("Horizontal") įloat moveZ = Input.GetAxisRaw("Vertical") We can move forwards, back, left and right relative to where we’re facing. lerAngles = new Vector3(curXRot, + (x * rotateSpeed), 0.0f) įinally, we want to implement the movement. Then if we’re holding down the right mouse button, we want to rotate the camera around.ĬurXRot = Mathf.Clamp(curXRot, minXRot, maxXRot) First, we have the code for zooming in and out with the scroll wheel.ĬurZoom += Input.GetAxis("Mouse ScrollWheel") * -zoomSpeed ĬurZoom = Mathf.Clamp(curZoom, minZoom, maxZoom) Ĭam.transform.localPosition = Vector3.up * curZoom In the Start function, we can setup some initial values and get the camera.įrom here on, we’ll be working inside of the Update function. ![]() Open the script up in Visual Studio so we can begin to create it. Here’s what it should look like in the Game view:Ĭreate a new C# script called CameraController and attach it to the CameraAnchor object. Then we can drag the Main Camera in as a child.Īlso on the Main Camera, let’s change our Field of View to 20. To begin, let’s create a new empty object called CameraAnchor. In this game, we’re going to have a camera which can move around, look and zoom in and out. This will open up the Lighting window where at the bottom, you can enable Auto Generate. To fix this, go to the bottom right corner of the screen and click on the Auto Generate Lighting button. You may notice that the lighting is a bit off. Set the Albedo Color to be a light green.Set the Albedo Texture to be the ground texture.In the Materials folder, create a new material called Ground and apply it to the ground plane. First, create a new 3D plane object and rename it to Ground. To begin, let’s create our base from where we’ll be placing buildings. In the Inspector, set the Albedo Texture to the relative texture PNG in the folderįinally, inside of the Textures folder, drag in the single image from the Textures Folder Contents folder.Then inside of our Models folder, drag in the assets from the Models Folder Contents.įor each of the materials in this folder: In the Inspector, set the Texture Type to Sprite (2D and UI).Inside of the Icons Folder Contents drag the 4 icons into the Unity project’s Icons folder. Download the ZIP file from the start of the tutorial and extract the contents to somewhere on your computer. Now let’s start importing the required assets such as 3D models and textures. In our new project, let’s start by creating some folders. First, let’s begin by creating a new Unity project with the 3D template. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |