Im trying to make a simple AI for my game but for some reason I keep getting this error:
error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.rotation’. Consider storing the value in a temporary variable.
Here’s my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class livingAI : MonoBehaviour {
public Transform AI;
public void FixedUpdate ()
{
AI.rotation.y = AI.rotation.y + Random.Range (-45, 45);
AI.transform.Translate (-5, 0, 0);
}
}
I’ve already tried multiple solutions i found on this forum, but none of them worked.