I’ve been trying to access the speed float with my other script. I can’t change the speed with the other script but I can with the script it is in. This is my enemy movement script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class EnemyMove : MonoBehaviour
{
public Transform player;
NavMeshAgent agent;
public static float speed = 1.0f;
// Start is called before the first frame update
void Start()
{
agent = GetComponent<NavMeshAgent>();
agent.speed = speed;
}
// Update is called once per frame
void Update()
{
//Follow the player
agent.destination = player.position;
}
}
This is the code I used to reference. I have a collision and whenever it collides, I want the speed to go up. I used this:
public static int left = 4;
EnemyMove.speed += 1.5f;
Please help I’ve searched everywhere couldn’t find an answer.
Thanks