- Home /
C# HUD axis button display
I am trying to get the button an axes is set to, but I can not find out how! There is not much to say, the code I have for this script is here.
using UnityEngine;
using System.Collections;
public class ForceFeildDoor : MonoBehaviour {
public Transform TargetObjectt;
public float RenderDist = 4;
public string KeyName;
// Use this for initialization
void Start () {
TargetObjectt = GameObject.FindGameObjectWithTag("Player").transform;
KeyName = Input.GetAxis("FullDrive");
}
// Update is called once per frame
void Update () {
float distancee = Vector3.Distance(transform.position, TargetObjectt.transform.position);
if (distancee <= RenderDist)
{
warning.mess = "Open Door [" + KeyName + "]";
}
}
}
Comment
Input.GetAxis("FullDrive") will return a float, not the keycode. How do you define "Fulldrive"? Input $$anonymous$$anager?
It seems like you're wanting to prompt the user to hit a key? If so, use Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.E) for example to hit $$anonymous$$ Also, you'll need warning.mess defined somewhere. $$anonymous$$aybe you want a GUIText or Text$$anonymous$$esh for the HUD?
warning.mess is on a script on a guitext. I really wanted to use the Input manager axis :(