using UnityEngine;
public class BackflipController : MonoBehaviour
{
public float backflipForce = 500f;
public float backflipRotationForce = 100f;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
PerformBackflip();
}
}
void PerformBackflip()
{
// Apply force upwards
rb.AddForce(Vector3.up * backflipForce);
// Apply torque for rotation
rb.AddTorque(transform.right * backflipRotationForce);
}
}
Comments