Calculating a Peek value for aiPlayer

There are no stupid questions, just stupid answers.
  • 1
  • 2
18 posts Page 1 of 2
Hodo33
Posts: 49
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Wed Sep 12, 2018 2:36 am
I am trying to hide from my bots and peek around a corner to see them. If I use SetAimObject they will shoot me if one inch is exposed using the los test.
I tried getobjectBox and then getworldboxcenter and calculate a percent of exposure which does not seem to effective. Does anyone have a simple way to see how much I am exposed to bot line of sight tests?
Duion
Posts: 1131
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Wed Sep 12, 2018 1:23 pm
How did you even manage to get the bots to be that good? I thought the bots aim for the center of the target, which should make them not shoot you if you just peek.

Otherwise I would just solve it with some getRandom value, like a roleplaying game, so you have a probability the bot can see you and shoot you, probably no human player will detect that your "algorithm" for that is just a random value.
Hodo33
Posts: 49
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Wed Sep 12, 2018 5:50 pm
%bot.setAimObject(%player)
%res = %bot.checkLosToObject(%player);
if(%res)
{
%bot.fire(true);
}

They shoot me through windows, door, at the edge of a building

right now to check los to object I use the boteye to playereye, if I change that to boteye to player worldboxcenter then I can stand in plain sight as long as half of my body is obscured which is also not realistic hence the question... thanks for the reply
Duion
Posts: 1131
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Wed Sep 12, 2018 6:41 pm
I don't even know what I use, all I know is they work fine. As an indie dev you have to learn how to be pragmatic, if it works good enough, don't bother with the details. You have to consider that if you change it, you may run into other problems, where the bot will not shoot a player even though for a human he is obviously visible, like you said with using worldboxcenter.

I would try to go with a simple workaround, like having a delay until the bot fires, like getRandom from 100ms to 2000ms , that way you do not notice when the bot sees you, since there is a random delay, or go the role play game route, where your visibility generates a percentage you get spottet, so if you are 20% visible, there is only a 20% change you get spotted, or some kind of algorithm, well really depends on the type of game.
Hodo33
Posts: 49
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Wed Sep 12, 2018 6:50 pm
Thanks for the suggestions, I like the getRandom idea, allows me to look and hide a bit better.
The game is a RPG shooter. I want the player to be more tactical and have to consider their actions rather than run and gun. I set their seek field of view narrow until I shoot one or just get right in front of him, then set off a base alert and make them aware of me. I time out the alert and they revert to just hanging around.
Duion
Posts: 1131
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Wed Sep 12, 2018 7:14 pm
Then the RPG system would be ideal probably, the elder scrolls series originally had a skill system that would go from 0 to 100, which would be the percentage an action would succeed, where of course there were other factors taken into account as well, as well as a little bit random to spice up the gameplay.

I think there is a function in Torque3D which checks how much of an object is visible, since I knew I had to bother with it for a postFX to determine how much of the sun is visible, maybe you can use that to determine how much a player is visible and then apply some kind of 0-100% detection rate based on that.
Online Razer
Posts: 38
Joined: Tue Jan 10, 2017 11:29 am
by Razer » Thu Dec 06, 2018 10:19 am
%bot.setAimObject(%player)
%res = %bot.checkLosToObject(%player);
if(%res)
{
%bot.fire(true);
}

They shoot me through windows, door, at the edge of a building

right now to check los to object I use the boteye to playereye, if I change that to boteye to player worldboxcenter then I can stand in plain sight as long as half of my body is obscured which is also not realistic hence the question... thanks for the reply
Add a check for each shoulder visibility, this will become some more accurate.
JeffR
Steering Committee
Steering Committee
Posts: 878
Joined: Tue Feb 03, 2015 9:49 pm
 
by JeffR » Thu Dec 06, 2018 4:21 pm
Expanding on Razer's idea, depending on how accurate you need the AI vision to be(obviously this is design dependent) one technique I've seen that better simulates sight/detection would be to randomly pick a point on the player's bounding box and fire a ray at it, instead of just their center.

If it hits, you add a small value to a detection bar(which degrades over time). This way you have the possibility of them spotting your foot or arm or whatnot, but it doesn't immediately make them go 'oh dang that's an enemy'

If you get a certain value on the 'detection' then they go into attack mode or whatnot, but because the value degrades, if they only get a glancing spot of you like your foot, they don't immediately attack.

This would be more relevent to something like a stealth game than a high-octane shooter.

If you need something simpler/more action oriented, then Duion's suggestion of random response delays or random detection chance would be pretty sufficient.
Steve_Yorkshire
Posts: 299
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Mon Dec 10, 2018 12:24 am
In Airship Dragoon I had a triple check for target visibility (getEyeNode, getWorldBoxCenter, getPosition), modified with range, which not only affected chance of being spotted but also decreased accuracy the less that was visible.
Bloodknight
Posts: 148
Joined: Tue Feb 03, 2015 8:58 pm
by Bloodknight » Mon Dec 10, 2018 1:31 am
i wonder if there's a way of detecting how much of the body is visible, tie that in with a line of sight angle modifier, so you get something like

-1% detection per degree of angle from the forward facing vector and then the modifier for % visible past the wall/cover
  • 1
  • 2
18 posts Page 1 of 2

Who is online

Users browsing this forum: Razer and 7 guests