using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Opponent : MonoBehaviour {
public class Ball;
float range;
float speed;
Rigidbody rb;
void Start()
{
rb=GetComponent<Rigidbody>();
}
void Update()
{
range = Vector3.Distance(Ball.transform.position, transform.position);
if (range < 40)
{
transform.LookAt(Ball.transform.position);
}
if (range < 30 && range > 15)
{
rb.AddForce(Vector3.forward*25*speed);
}
}
}
I need some help with this code, it is meant to be a script for an AI that will chase a ball. I have been working on it for a few weeks for a school project but I am still getting a compiler error telling me that I am missing { and } somewhere within the script. I have tried multiple positions and looked at other forums for help but I am still getting the error. Can anyone help me out or point out where I have gone wrong with the end brackets? Thanks