Unityde 2d oyunda karakterin 360 derece dönüşlerini saymak istiyorum nasıl yapabilirim?
Aşağıda karakterin hareketi ile ilgili kod var
Aşağıda karakterin hareketi ile ilgili kod var
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class torque : MonoBehaviour
{
Rigidbody2D rb;
[SerializeField] float torquem;
public float boostspeed = 40f;
public float normalspeed = 25f;
SurfaceEffector2D surfaceEffector2D;
bool isabled = true;
void Start()
{
rb = GetComponent<Rigidbody2D>();
surfaceEffector2D = FindObjectOfType<SurfaceEffector2D>();
}
void Update()
{
if (isabled)
{
torqueekle();
hizekle();
}
}
public void disable()
{
isabled = false;
}
void torqueekle()
{
if (Input.GetKey(KeyCode.LeftArrow))
{
rb.AddTorque(torquem);
}
if (Input.GetKey(KeyCode.RightArrow))
{
rb.AddTorque(-torquem);
}
}
void hizekle()
{
if (Input.GetKey(KeyCode.UpArrow))
{
surfaceEffector2D.speed = boostspeed;
}
else
{
surfaceEffector2D.speed = normalspeed;
}
}
}