Forum Discussion
my3dscene
12 years agoProtege
Select by looking something for a few seconds
Hi guys,
at the moment I am working in Javascript to add this feature in my project. However I am having some issues.
What I am doing is attach a non renderable stretched box to my right camera (like a ray from my head) in order to collide with a second box when you look at it, and then "yield" for a few seconds.
Just wondering to know if any of you guys have a better script than my non functional Javascript one.
at the moment I am working in Javascript to add this feature in my project. However I am having some issues.
What I am doing is attach a non renderable stretched box to my right camera (like a ray from my head) in order to collide with a second box when you look at it, and then "yield" for a few seconds.
Just wondering to know if any of you guys have a better script than my non functional Javascript one.
4 Replies
Replies have been turned off for this discussion
- MikeFTrusteeyou could do something like:
var LookingAtObject : bool = false;
var LookAtTimer : float = 0.0f;
var LookAtTimeLimit : float = 3.0f
function Update()
{
if (LookingAtObject == true){
LookAtTimer += time.deltaTime
}
if (LookAtTimer >= LookAtTimeLimit){
doSomething
}
}
function OnTriggerEnter (other : Collider) {
LookingAtObject = true;
}
function OnTriggerExit (other : Collider) {
LookingAtObject = false;
LookAtTimer = 0.0f;
}
I havent tested this but that should be the just of it - my3dsceneProtege
"MikeF" wrote:
you could do something like:
var LookingAtObject : bool = false;
var LookAtTimer : float = 0.0f;
var LookAtTimeLimit : float = 3.0f
function Update()
{
if (LookingAtObject == true){
LookAtTimer += time.deltaTime
}
if (LookAtTimer >= LookAtTimeLimit){
doSomething
}
}
function OnTriggerEnter (other : Collider) {
LookingAtObject = true;
}
function OnTriggerExit (other : Collider) {
LookingAtObject = false;
LookAtTimer = 0.0f;
}
I havent tested this but that should be the just of it
Tnks master mike, I will let you know how it works. - my3dsceneProtegeit works, I had to tweak a bit the code, since "Bool" wasn't very friendly with Javascript, but the structure is the same. I have also added animations and sound and works perfectly.
Tnks Master. - MikeFTrusteeno problem, glad i could help!
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 4 months agoAnonymous
- 3 years ago
- 5 years ago