Anda di halaman 1dari 2

1.

Buatlah lantai dengan Plane selebar mungkin


2. Buat Dinding luar dan dalam menggunakan cube dan buat seperti labirin
3. Buat pencahayaan menggunakan point light hapus directional light di hirarchy
4. Pada Inspector Point Light ubah Warna pencahayaan menjadi oranye
5. Masih dalam Inspector ubah rangenya menjadi 40
6. Masih dalam Inspector Intensity menjadi 2
7. Buat 3d Object Capsule
8. Ganti nama 3D Object menjadi Player
9. Buat 3d Object Capsule
10. Ganti nama CapsulePutar
11. Jadikan Main Camera child dari Player
12. Buat script C#
using UnityEngine;
using System.Collections;
public class Spin : MonoBehaviour
{
public float speed = 0 ;
void Update()
{
transform.Rotate(0, 0, speed);
}
}
13. Masukan script ke dalam CapsulePutar, maka objek akan berputar
sesuai dengan speed rotasi hanya berputar di sudut z saja
urutannya (x,y,z), silahkan coba di y dan di x
14. Untuk membuat player bergerak di semua sumbu baik x,y,z dengan\
menggunakan mouse buatlah script MouseLook
15. using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouseLook : MonoBehaviour


{
public enum RotationAxes{
MouseXAndY = 0,
MouseX = 1,
MouseY = 2
}
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityHor = 45.0f;
public float sensitivityVert = 45.0f;
public float minimumVert = 45.0f;
public float maximumVert = 45.0f;
private float rotationX = 0;
void Start()
{
Rigidbody body = GetComponent<Rigidbody>();
if (body != null)
body.freezeRotation = true;
}
void Update()
{
if (axes == RotationAxes.MouseX)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityHor,
0);
}
else if (axes == RotationAxes.MouseY)
{
rotationX -= Input.GetAxis("Mouse Y") * sensitivityVert;
rotationX = Mathf.Clamp(rotationX, minimumVert, maximumVert);
float rotationY = transform.localEulerAngles.y;
transform.localEulerAngles = new Vector3(rotationX, rotationY,
0);
}
else
{
rotationX -= Input.GetAxis("Mouse Y") * sensitivityVert;
rotationX = Mathf.Clamp(rotationX, minimumVert, maximumVert);
float delta = Input.GetAxis("Mouse X") * sensitivityHor;
float rotationY = transform.localEulerAngles.y + delta;
transform.localEulerAngles = new Vector3(rotationX, rotationY,
0);
}
}
}

16. Untuk membuat Tombol fokus panah (seperti layar tembak) pada player
17. Buat Script C# PlayerGUI
using System.Collections;
using UnityEngine;

public class PlayerGUI : MonoBehaviour


{
[SerializeField]
Texture2D crosshair;
// Start is called before the first frame update
void OnGUI()
{
float x = (Screen.width - crosshair.width) / 2;
float y = (Screen.height - crosshair.height) / 2;
GUI.DrawTexture(new Rect(x, y, crosshair.width, crosshair.height),
crosshair);
}

}
18. Sebelum play masukan design crooshair terlebih dahulu,
baiknya cari di google lalu drag ke dalam crooshair
19. Selesai

Anda mungkin juga menyukai