- Home /
Starting/Triggering events based on hover time
I am trying to start multiple things based on looking at something. After a period of time a event gets triggered (load next level in this case). Here is the pseudo code:
using UnityEngine; using System.Collections;
public class loadLevelFromHoover : MonoBehaviour {
public float timer = 3.0f;
public Animation hoverAnimation;
public ParticleEmitter hoverParticle;
public bool isHovering = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void hooverOver()
{
if (isHovering == true)
{
Start timer;
Start hoverAnimation
Start hoverParticle
}
if (isHovering == false)
{
reset timer
stop amination
stop particle
}
}
void loadLevel()
{
if (timer <= 0.0f)
{
Application.LoadLevel(int loadedlevel++);
}
}
}
I have another script that determines if the object is hovered over (selected). This uses raycast so I can already get the "isHovering" bool to change.
Any help is appreciated.
Thanks Trevor
Comment
Your answer
Follow this Question
Related Questions
reset the level? 5 Answers
Reset The Scene ? 2 Answers
Time limit on my game with selection menu 0 Answers
Reset the countdown timer 2 Answers
How To Reset Timer on a Collision (C#) 0 Answers