I am trying to rotate a player when it hits a wall.
I get this error: Operator + cannot be applied to operands of type ‘Quaternion’ and ‘Quaternion’.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Wallcheck : MonoBehaviour
{
public GameObject text;
public Transform player;
public float speed = 0.1f;
void OnCollisionEnter(Collision Collision)
{
Debug.Log("Touched");
text.SetActive(true);
}
void OnCollisionStay()
{
if(Input.GetButton("Gravity"))
{
Debug.Log("RotateGrav");
}
Quaternion startAngle = player.transform.rotation;
Quaternion targetAngle = startAngle + Quaternion.Euler(-90f, 0f, 0f);
transform.rotation = Quaternion.Lerp(startAngle, targetAngle, Time.time * speed);
}
void OnCollisionExit(Collision Collision)
{
Debug.Log("Stopped touching");
text.SetActive(false);
}
}
Any help on how to fix it would be appreciated.