Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Set Text Field To The Key of A Certain Input

Discussion in 'Scripting' started by GrayWoolsey, Jul 26, 2020.

  1. GrayWoolsey

    GrayWoolsey

    Joined:
    Apr 20, 2018
    Posts:
    27
    For NPCs in my project when you walk up to them and look at them it says "Speak With Whoever" but I want it to show the interaction key.

    I have an Input for Interact set to E and I want the text to say

    " 'E' Speak With Whoever "

    interactionText.text = (Input.GetKey("Interact").ToString() + " Speak With " + hit.collider.tag.ToString());
     
  2. AnthonySharp

    AnthonySharp

    Joined:
    Apr 11, 2017
    Posts:
    88
    Call me crazy but couldn't you just do

    Code (CSharp):
    1. interactionText.text = "'E'" + " Speak With " + hit.collider.tag.ToString();
     
  3. GrayWoolsey

    GrayWoolsey

    Joined:
    Apr 20, 2018
    Posts:
    27
    Well if the player were to change their controls I want it to pull from the input manager so that it changes.
     
  4. AnthonySharp

    AnthonySharp

    Joined:
    Apr 11, 2017
    Posts:
    88
  5. GrayWoolsey

    GrayWoolsey

    Joined:
    Apr 20, 2018
    Posts:
    27
  6. GrayWoolsey

    GrayWoolsey

    Joined:
    Apr 20, 2018
    Posts:
    27
    Am I really going to have to write my own input manager?
     
  7. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    AnthonySharp likes this.