Author Topic: Psuedocode for clicking and holding + time?  (Read 1236 times)

Trying to run an onTrigger raycast that requires the player to hold down their left click for 10 seconds while continuously looking at a set object. Once the 10 seconds of held click are over, a function is passed. What's the most efficient way to go around this?

You could do a trace(1) when doing it normally to figure out what functions are called.

would probably be to have onTrigger activate a schedule loop that continuously checks to see if the player is still looking at the object

keep track of the start time using $Sim::Time and when $Sim::Time - start time >= 10 call the function and break out of the loop

if the player releases the button, cancel the schedule

You could do a trace(1) when doing it normally to figure out what functions are called.
I already know that. I already know the namespace and function for OnTrigger, I just need help running it on loop for a click and hold effect.

would probably be to have onTrigger activate a schedule loop that continuously checks to see if the player is still looking at the object

keep track of the start time using $Sim::Time and when $Sim::Time - start time >= 10 call the function and break out of the loop

if the player releases the button, cancel the schedule
Wait, what functions control holding a trigger and releasing it?

Wait, what functions control holding a trigger and releasing it?
onTrigger does

the last argument is 1 when the button is pressed and 0 when it's released

onTrigger does

the last argument is 1 when the button is pressed and 0 when it's released
ah alright i'll try this

Alright, different question: How can I get the player to go orbit camera on themselves while they hold down the mouse button without the camera's movement ruining the raycast direction?
« Last Edit: January 17, 2016, 01:32:23 PM by Path »

quickbump, important

Orbit cameras transform shouldn't affect the raycast as long as you're using data you gathered from the player.

If the player isn't moving, then doing constant raycasts isn't exactly necessary, unless they need to be looking at an object that could possibly be moving.

If the player isn't moving, then doing constant raycasts isn't exactly necessary, unless they need to be looking at an object that could possibly be moving.
This.

If the object is stationary, you can simply record/monitor the players rotation and check/compare it later.

Another way: You can also set the camera to only orbit the player so that the client has no control over it.
« Last Edit: January 18, 2016, 07:08:28 AM by Honorabl3 »

probably best to use the eye vector because look pitch isn't included in the transform value