This is the script
using UnityEngine;
using System.Collections;
public class MakeObjectFly : MonoBehaviour
{
public float AmbientSpeed = 100.0f;
public float RotationSpeed = 200.0f;
public float flightSpeed = 5.0f;
public float landingSpeed = 100.0f;
public bool isGrounded = true;
Rigidbody _rigidbody;
GUIText displaylandingspeed;
void Start()
{
_rigidbody = GetComponent<Rigidbody> ();
}
void Update ()
{
Quaternion AddRot = Quaternion.identity;
float roll = 0;
float pitch = 0;
float yaw = 0;
roll = Input.GetAxis ("Roll") * (Time.deltaTime * RotationSpeed);
pitch = Input.GetAxis ("Pitch") * (Time.deltaTime * RotationSpeed);
yaw = Input.GetAxis ("Yaw") * (Time.deltaTime * RotationSpeed);
AddRot.eulerAngles = new Vector3 (-pitch, yaw, -roll);
_rigidbody.rotation *= AddRot;
Vector3 AddPos = Vector3.forward;
AddPos = _rigidbody.rotation * AddPos;
if (isGrounded == true) {
landingSpeed = Input.GetAxis ("LandingSpeed") * (Time.deltaTime * AmbientSpeed);
_rigidbody.velocity = AddPos * (Time.deltaTime * AmbientSpeed + landingSpeed);
if (landingSpeed == 100)
landingSpeed = 0.0f;
displaylandingspeed.text = landingSpeed.ToString ();
}
}
}
I want to display for now only the landingSpeed value in real time on the screen and not in the middle of the screen let’s say on the left top corner.
So i added a GUIText variable but when building the script i’m getting warning on:
GUIText displaylandingspeed;
Assets/MyScripts/MakeObjectFly.cs(14,17): warning CS0649: Field MakeObjectFly.displaylandingspeed' is never assigned to, and will always have its default value
null’