Quantcast
Channel: Latest Questions by Vidar
Viewing all articles
Browse latest Browse all 12

Same triggers seem to annoy each other

$
0
0

Hey Guys,

I have a Problem with two triggers that just have the function two show and hide a thoughtbubble over the player. There's a TimeOut to each trigger that says after what time, the thoughtbubble should disappear. The thoughtbubble is attached to my Player and changes the text whenever a trigger is hit.

Now when i walk in the first trigger, and wait till the TimeOut is reached, and then walk in the second trigger, everything is fine and the second bubble is shown.

But when i walk in the first one, and walk in the second trigger while the first bubble is still visible, it starts to bug, for example i can't walk in the second trigger anymore, or the bubble is only shown 1 second or so.

I hope everything is clear so far, my Code of both Triggers:

//Text which will be displayed in the thought bubble on entering trigger
var ThoughtBubbleID = 0;
private var helpText : String;
//Time for which the thought bubble will be displayed
var timeOut = 1.0;
private var triggerTime = -1.0;
private var playerStatus : PlayerStatus;
private var test;

function Update () {

//test = triggerTime + timeOut;
//Debug.Log(Time.time + " " + test);

if (Time.time > triggerTime+timeOut) {
    triggerTime = -1.0;

    if (playerStatus) {
        playerStatus.DontThink();
        playerStatus = null;
    }
}
}

function OnTriggerEnter (col:Collider) {

if (triggerTime > 0)
    return;

helpText = XMLData.node["thoughtbubbles"][0]["thoughtbubble"][ThoughtBubbleID-1]["text"][0]["_text"];

playerStatus = col.GetComponent(PlayerStatus);
if (helpText && playerStatus) {
    playerStatus.Think(helpText);
    triggerTime = Time.time;
}
}

function OnDrawGizmos () {
Gizmos.DrawIcon (transform.position, "Bubble.psd");
}

Viewing all articles
Browse latest Browse all 12

Latest Images

Trending Articles





Latest Images