- Home /
What tools can I use to track the duration of collision (of eye movement with an object)
I am working on a project in which I am planning to track the duration of time my agent looks at a certain object. The agent's vision is in the form a laser beam. So, right now I am using collisions to detect where the agent is looking but what tools can I use to detect the duration of gaze?
Answer by RufusHolton · Aug 24, 2020 at 03:32 PM
i would right a script that starts a timer when the agent looks at something then all u need to do is check whether the agent has looked away from the object in which u would just reset the timer
for example:
//i will be using raycast for example
float timer = 3; //ur time here
float timerSave;
void Start()
{
timerSave = timer;
}
void Update()
{
RaycastHit hit;
if(Physics.Raycast(agent, dir, out hit, dist))
{
if(timer <= 0)
{
//timer has reached bottom
}
else
{
timer -= Time.deltaTime;
return;
}
}
else
{
//reset timer, agent has looked away
timer = timerSave;
}
}
havent tested it so it might not work but think it should
Your answer
Follow this Question
Related Questions
Trigger script does not work. 1 Answer
move camera when it collides with a trigger 1 Answer
OnCollisionEnter Sine Wave to Character 0 Answers
Player not colliding 0 Answers
Help With Colliders 3 Answers