Im trying to access the variable "EnginePower" from the script AeroplaneController see code below
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Speed : MonoBehaviour
{
public GameObject Aircraft;
public Text SpeedText;
public float FSpeed;
// Update is called once per frame
void Update()
{
FSpeed = Aircraft.GetComponent<AeroplaneController>().EnginePower * 5.714285714285714;
}
}
As you can see, Im setting FSpeed to be equal to EnginePower multiplied by 5.714285714285714
But im getting the error The type or namespace name 'AeroplaneController' could not be found (are you missing a using directive or an assembly reference?)
EnginePower IS public, AeroplaneController is a Unity StandardAssets script.
>Solution :
Adding to what @LafiteCandy said:
Change Aircraft.GetComponent<AeroplaneController>() to Aircraft.GetComponent<UnityStandardAssets.Vehicles.Aeroplane.AeroplaneController>()