Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I'm getting an error when I try to access `EnginePower` from Unity StandardAssets script

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Adding to what @LafiteCandy said:

Change Aircraft.GetComponent<AeroplaneController>() to Aircraft.GetComponent<UnityStandardAssets.Vehicles.Aeroplane.AeroplaneController>()

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading