I have been trying to change a variable from a script for an RPG game I’m trying to make although it won’t seem to register the other script. I’m having an AI cause the player to take damage. I have been trying this over and over again but it won’t register it. I’m certain I have the script correct because I tried typing in the name of the AI script (which the code below is in) and it registered it.
using UnityEngine.UI;
public class AIController : MonoBehaviour
{
public Transform Player;
public GameObject PlayerVariable;
int MoveSpeed = 4;
void Start()
{
}
void Update()
{
transform.LookAt(Player);
transform.position += transform.forward * MoveSpeed * Time.deltaTime;
}
void OnTriggerEnter(Collider col)
{
if (col.tag == "Player")
{
PlayerVariable.GetComponent<PlayerStats> ().Attack = true;
PlayerVariable.GetComponent<PlayerStats> ().Damage = 2;
PlayerVariable.GetComponent<PlayerStats> ().DamageSpeed = 2;
}
}
}
This is the Error it says. The line it’s on is where it changes the variable.
The type or namespace name `PlayerStats’ could not be found. Are you missing an assembly reference?