Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class araba_hareket : MonoBehaviour
{
public GameObject onsagtekerlek, onsoltekerlek, arkasagtekerlek, arkasoltekerlek;
public bool wbool, abool, dbool, sbool, basili;
public float hiz;
public GameObject araba;
public float dönmehizi;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (wbool == true)
{
hiz += Time.deltaTime * 3;
araba.transform.Translate(0, 0, Time.deltaTime * hiz);
}
if (wbool == true && abool == true)
{
hiz += Time.deltaTime * 3;
araba.transform.Translate(0, 0, Time.deltaTime * hiz);
araba.transform.Rotate(0, Time.deltaTime * -dönmehizi, 0);
}
if (wbool == true && dbool == true)
{
hiz += Time.deltaTime * 3;
araba.transform.Translate(0, 0, Time.deltaTime * hiz);
araba.transform.Rotate(0, Time.deltaTime * dönmehizi, 0);
}
if (sbool == true)
{
hiz += Time.deltaTime * 3;
araba.transform.Translate(0, 0, Time.deltaTime * -hiz);
}
if (abool == true)
{
onsagtekerlek.transform.eulerAngles = new Vector3(0, -35, 0);
onsoltekerlek.transform.eulerAngles = new Vector3(0, -35, 0);
}
else if (dbool == true)
{
onsagtekerlek.transform.eulerAngles = new Vector3(0, 35, 0);
onsoltekerlek.transform.eulerAngles = new Vector3(0, 35, 0);
}
else
{
onsagtekerlek.transform.eulerAngles = new Vector3(0, 0, 0);
onsoltekerlek.transform.eulerAngles = new Vector3(0, 0, 0);
}
if (Input.GetKey(KeyCode.A))
{
abool = true;
}
else
{
abool = false;
}
if (Input.GetKey(KeyCode.D))
{
dbool = true;
}
else
{
dbool = false;
}
if (Input.GetKey(KeyCode.S))
{
sbool = true;
}
else
{
sbool = false;
}
if (Input.GetKey(KeyCode.W))
{
wbool = true;
}
else
{
wbool = false;
}
if (hiz >= 45)
{
hiz = 45;
}
}
}