UNİTY 3D FUNCTIONS - PLAYER MOVEMENT
PLAYER MOVEMENT:
{
//Player
Movement
public float speed;
//Flashlight
private bool aciksa;
public GameObject flashlight;
private void Start()
{
aciksa = true;
}
private void Update()
{
Vector3 playerInput = new Vector3(Input.GetAxis("Horizontal"), 0f,
Input.GetAxis("Vertical"));
Vector3 moveVelocity = playerInput *
Time.deltaTime * speed;
// moveVelocity
= Hareket Etme Hızı
transform.position += moveVelocity;
//Flaslight
if
(Input.GetKeyDown(KeyCode.F))
{
if
(aciksa)
{
flashlight.GetComponent<Light>().enabled = false;
aciksa = false;
}
else
{
flashlight.GetComponent<Light>().enabled = true;
aciksa = true;
}
}
}
}
Yukarıdaki sarı ile çizdiğim kodlar BİR ÖNCEKİ DERSTEN KALMA
FENER AÇIP KAPATMA KODLARIDIR. Diğerleri bu derste yaptığımız objenin
hareketini sağlamak için yazdığımız kodlardır. Bu kodlar sayesinde obje oyun
başladığında hareket eder.
Hiç yorum yok: