Search Unity

Dialogie repeat on click car object

Discussion in 'Scripting' started by Melchet, Feb 17, 2015.

  1. Melchet

    Melchet

    Joined:
    Feb 5, 2015
    Posts:
    15
    Hello everyone,

    Could someone help me with this:

    I'm making an horror game.

    Like every other game I would like an effect you click on object and a single dialogue comes.

    I have an car as object:

    I would like if you click with the 'E 'button you get dialogue: I cannot start my car. And you click the 'continue button. But it's repeatable. Only at the car, not the whole area.
     
    Last edited: Feb 17, 2015
  2. Jmanpie

    Jmanpie

    Joined:
    Oct 7, 2012
    Posts:
    132
    store all the message in an array of string then you could use a switch statement to get the name of the object and pass the number to a function which gets the dialogue from the array and displays it in a textbox.
    get the key input (E)
    http://docs.unity3d.com/ScriptReference/Input.GetKeyDown.html

    How to use text
    http://unity3d.com/learn/tutorials/modules/beginner/ui/ui-text

    Event manager to send the messages of what to display.
    http://unity3d.com/learn/tutorials/modules/beginner/ui/ui-events-and-event-triggers

    arrays
    http://docs.unity3d.com/ScriptReference/Array.html

    Switch statments
    http://unity3d.com/learn/tutorials/modules/beginner/scripting/switch

    you will need raycasts as well
    http://docs.unity3d.com/ScriptReference/Physics.Raycast.html
     
  3. Melchet

    Melchet

    Joined:
    Feb 5, 2015
    Posts:
    15
    Well,

    I'm bad at scripting,
    So I don't know how it al works, that's why I calling for help :)