Hi all,
I have a sight conditional that, while raycast hits player, increments a sightPercent variable and returns TaskStatus.Running.
When sightPercent reaches 1, it TaskStatus.Success Is returned and enemy can now 'see' player and act accordingly.
While raycast hit is maintained and sightPercent increases, an event is fired passing some variables, which a UI component uses to draw the familiar 'how much has the enemy seen me' display.
This all works fine, however it currently resets the sightPercent to zero whenever the enemy loses raycast hit.
I would like that the sightPercent of an enemy slowly returns to zero over time while raycast does not hit, letting an enemy that nearly 'saw' player to more quickly 'see' player if raycast hit is reacquired soon after losing it. The longer the player stays out of sight, the longer it will take enemy to 'see' player when next in the open.
Since the sight conditional returns TaskStatus.Failure when no raycast hit, it is no longer able to decrease the sightPercent over time.
I was thinking something like having the sightPercent as a shared value and allow it to be increased by this script as raycast hit is maintained but also another that can decrease it. I can't visualise how this would work, however, in conjunction with other tasks.
Perhaps a 'cannot see player' task that just handles this value?
How would you handle such a scenario?
Cheers
Oli
I have a sight conditional that, while raycast hits player, increments a sightPercent variable and returns TaskStatus.Running.
When sightPercent reaches 1, it TaskStatus.Success Is returned and enemy can now 'see' player and act accordingly.
While raycast hit is maintained and sightPercent increases, an event is fired passing some variables, which a UI component uses to draw the familiar 'how much has the enemy seen me' display.
This all works fine, however it currently resets the sightPercent to zero whenever the enemy loses raycast hit.
I would like that the sightPercent of an enemy slowly returns to zero over time while raycast does not hit, letting an enemy that nearly 'saw' player to more quickly 'see' player if raycast hit is reacquired soon after losing it. The longer the player stays out of sight, the longer it will take enemy to 'see' player when next in the open.
Since the sight conditional returns TaskStatus.Failure when no raycast hit, it is no longer able to decrease the sightPercent over time.
I was thinking something like having the sightPercent as a shared value and allow it to be increased by this script as raycast hit is maintained but also another that can decrease it. I can't visualise how this would work, however, in conjunction with other tasks.
Perhaps a 'cannot see player' task that just handles this value?
How would you handle such a scenario?
Cheers
Oli