If successful collision reverse rotation of object
How can I code a script so that if a collision is successful the controller reverses the rotation of the player controller. This is the code: using UnityEngine; using System.Collections;
public class PlayerControl : MonoBehaviour
{
public float turnAngle = 90;
public float turnSpeed = 40;
private float angle;
private Transform T;
void Awake()
{
this.enabled = false;
}
void Start()
{
T = GetComponent<Transform>();
}
void Update()
{
if (Input.GetMouseButtonDown(0))
angle += -turnAngle;
T.rotation = Quaternion.Slerp(T.rotation, Quaternion.Euler(0, 0, angle), Time.deltaTime * turnSpeed);
}
Comment
So when I click ins$$anonymous$$d of rotating the object clockwise it rotates it anticlockwise then if there is another collision when I click it rotates the object clockwise and visa versa