Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions Assets/PlaneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public class PlaneController : MonoBehaviour
// Sağa/sola dönüşlerde uçağın daha hızlı yön değiştirebilmesi için
// bankeden elde edilen dönüş hızını artırıyoruz.
public float bankTurnSpeed = 50f;
// Doğrudan yön tuşları ile uygulanacak yaw hızı
public float yawSpeed = 45f;
// Yön tuşları bırakıldığında uçağı kendiliğinden düzleme hızı
public float autoLevelSpeed = 2f;

private Rigidbody rb;

Expand All @@ -26,16 +30,32 @@ void FixedUpdate()
// INPUT – Yön tuşları
float pitchInput = 0f;
float rollInput = 0f;
float yawInput = 0f;

if (Input.GetKey(KeyCode.UpArrow)) pitchInput = 1f;
if (Input.GetKey(KeyCode.DownArrow)) pitchInput = -1f;
if (Input.GetKey(KeyCode.LeftArrow)) rollInput = -1f;
if (Input.GetKey(KeyCode.RightArrow)) rollInput = 1f;
if (Input.GetKey(KeyCode.LeftArrow))
{
rollInput = -1f;
yawInput = -1f;
}
if (Input.GetKey(KeyCode.RightArrow))
{
rollInput = 1f;
yawInput = 1f;
}

// Yön tuşlarına basılmadığında yavaşça düzleşme
if (!Input.GetKey(KeyCode.LeftArrow) && !Input.GetKey(KeyCode.RightArrow))
{
float bankAmount = Vector3.Dot(rb.rotation * Vector3.right, Vector3.up);
rollInput = -bankAmount * autoLevelSpeed;
}

// ROTASYON – Uçağı döndür (pitch ve roll)
Quaternion deltaRotation = Quaternion.Euler(
pitchInput * pitchSpeed * Time.fixedDeltaTime,
0f,
yawInput * yawSpeed * Time.fixedDeltaTime,
-rollInput * rollSpeed * Time.fixedDeltaTime
);

Expand All @@ -53,7 +73,7 @@ void FixedUpdate()
// döndürerek yeni yönü oluştur
Quaternion yawRotation = Quaternion.Euler(
0f,
bankAmount * bankTurnSpeed * Time.fixedDeltaTime,
-bankAmount * bankTurnSpeed * Time.fixedDeltaTime,
0f
);
direction = yawRotation * direction;
Expand Down