Hello!! I'm having trouble getting this script to work :P Basically I'm using Royce Kimmon's dialogue engine/generator, and I'm trying to make a trigger for it. Basically i wanna be able to click on the object thats going to be talking, but i wanna make it so they have to be within a certain distance of the object to be able to talk to it.
Here is what i got so far (if you have any tips, please say xD I just started programming yesterday):
var talkmessage : boolean;
var target : Transform;
function Start () {
var d : DialogueInstance = gameObject.GetComponent(DialogueInstance);
if (d) d.enabled = false;
talkmessage = false;
}
function OnMouseOver () {
var d : DialogueInstance = gameObject.GetComponent(DialogueInstance);
if(talkmessage) {
if(Input.GetButtonDown("Fire1")) {
d.enabled = true;
}
}
}
function Update () {
if ( Vector3.Distance(target.position, transform.position ) < 25) {
talkmessage = true;
}
if ( Vector3.Distance(target.position, transform.position ) > 25) {
talkmessage = false;
}
}
And i have target.position set to my player. This script is being applied on my object.
Thanks guys!!! Hoping I'll be able to help noobs like me eventually!