First off, a quick UI design question. Is there any particular reason that visual sensors range and requires line of sight options are hidden in the advanced options? That seems like a basic one to me. Waypoint names are another that seem pretty important but are only in the advanced view.
Minor bug that may be a Unity thing but I figured I’d mention it. I seem to get some UI corruption that only affects the RAIN inspector and behavior editor. It seems that after about 10 minutes I have to restart Unity to get it working: http://cl.ly/SxWK I don’t see anything out of the ordinary in the Editor logs but I’ll keep looking.
On to the actual question. The goal is to setup some squad based tactics. Basic stuff like cover fire from one unit while another moves. What I currently have setup is a single unit that patrols until it senses the player. Once it senses the player it looks for the nearest cover (waypoint rig with cover positions named so they can be located). The unit runs to cover then starts firing at the player. I would like to expand this to a squad of units sharing the same waypoint rig. When one unit senses the player I’d like to alert all the units. When a unit runs for cover I want to make sure other units don’t try to go for the same cover location on the waypoint rig. I also want to keep units spread out so they are more of a challenge to deal with and don’t just bumble around running into each other.
What is “the RAIN way” to do something like this? I’m basically just looking for a starting point so that I can run with it but I don’t want to hack together some crazy communication system without first seeing how RAIN was setup to handle situations like this.
-
This topic was modified 1 year, 11 months ago by desaro.
Sensors shouldn’t have a performance hit unless:
1) You have hundreds of Aspects,
2) You are using Line of Sight checks
3) Many of those Aspects are within sensor range.
We’re continuing to work to improve performance across RAIN. The next patch has a number of improvements for speed and memory efficiency.
@markfrancombe,
Just a few random thoughts…
1) You could set up an Expression node to set “foundplayer = false” to reset when the NPC reaches his “home”. I think you said your sensor was set to use line of sight. So, if the player chases him home, he shouldn’t be able to “see” him. I assume you meant FALSE when you said NULL.
2) In a different thread, I recall @prime mentioned using two sensors to detect different distances to determine when to perform a melee attack behavior versus a ranged attack behavior. The new sensors are “passive” (from what I read elsewhere on these forums) so they should be less of a resource drain, but if you have a lot of NPCs with multiple sensors you may experience a performance drop (don’t quote me on that, I’m only creating a single NPC with a single sensor at the moment).
If you want to code it, you could do a distance check between the player and the NPC and if it was < 25 meters do one behavior and if it’s > 25 meters walk slowly to destination.
3) Maybe I didn’t set it up right, but I wasn’t able to get collision avoidance working using RAIN. I ended up using Unity’s built in NavMesh generation, NavMeshAgent and NavMeshObstacle. If you attach a NavMeshAgent to your Player and a NavMeshAgent to your NPC, when he gets close to you he should steer around you. NOTE: I haven’t tested this, but I noticed that if I run toward my NPCs, they avoid each other but I can pass through them like a ghost.
The NavMeshObstacle (Unity Pro only) was something I actually needed in my current project, so for now Unity NavMesh is the option I have to use. I need to move around an obstacle (vehicle door).
Anyway, just some thoughts. Hope that helps a little or at least gives you some ideas.
Make sure that, if the mount point is inside the colliders on the player, you set up the line of sight mask so that it ignores those colliders.
FPSCamera was just a point on my character rig, kinda head height… And yes I do have require line of sight checked. This is because its for a part of my game where you must creep up on some AI talking and overhear their conversation, if they see you they run off.
Mark
Where is the FPSCamera you are using for a mount point? And do you have RequireLineOfSight checked in your Sensor? (Thanks for all the various screenshots. It helps.)
Yes, I thought about using the Line of Sight Mask, but my problem is how to ignore just the terrain, because the options list of the line of sight mask is just:
·Nothing
·Everything
·Default
·TransparentFX
·Ignore Raycast
·Water
There’s no option to permit ignoring the terrain. Maybe creating a custom action to overide the Require Line of Sight?
Line of sight has a layer mask. You could use that to ignore the terrain. However, why does the AI stop when the player is looking at them? If it is intended to mimic the AI’s awareness of the player, then allowing the terrain to block the line of sight seems like a good thing. If it is simply a game mechanic, then I wouldn’t use sensors for it, but instead write some custom logic, as in the 3rd option.
Thank you very much! It worked for me, I just put a sphere with entity behind the player and activated the line of sight of a visual sensor, then, if I’m facing the NPC, it won’t move because the Player is blocking the vision of the NPC. BUT, this solution has a problem, which is that when the terrain blocks the vision of the NPC it also stops. So now I need to tell to the AI’s Line of Sight to ignore the terrain, how could that be done?
Thanks again
Lots of ways to deal with it.
- you could just have the player object tell the AI when it is looking at it. Have a component on the player that grabs the AI rig, then sets a variable in AI working memory, like
rig.AI.WorkingMemory.SetItem("playerseesme", lookingAtAI);
- you could put an aspect on the player, mounted near his eyes but outside his collider. Then use a sensor on the AI to with a Line of Sight check.
- you could have the AI do a check on the forward angle of the player vs the angle from player to AI. If those are within some # of degrees, then set a variable to indicate “playerseesme” as above.
Hi Guys,
I have updated my rain to version 2.0.6, but it looks like i am still missing the line of sight accesor under the visual sensor, is this correct?
http://puu.sh/5m1Tz.jpg link to my screenshot.
Thanks in advance.
Well I found te problem already, Rain needed to be putted in advanced modus. RAIN > Help > Settings > Show Advanced
-
This reply was modified 2 years ago by Juggernaut.
-
This reply was modified 2 years ago by Juggernaut.
@prime, can you bring visualization of the raycast line for line of sight like there was in RAIN{indie}? I miss this feature.
Release notes RAIN 2.0.6 patch update:
Important Alert: If you are trying to update RAIN and your build setting are set to Web Player, RAIN will not update. Set your build settings to any other platform to update RAIN then change your settings back.
Added missing LineOfSight property accessors to Visual Sensor
API changes to RAINNavigator to do a better job of checking OnGraph
Changes to AI Memory to remove virtual generic methods that were causing issues on IOS
Fixed BT Editor node dragging crash
Fixed issues with Mecanim IK/Animation
Added API methods to Motor for detecting whether you are at/facing a target.
RAIN now compiles for Windows 8 Phone/App Store
RAIN now runs correctly on iOS
Fixed Mecanim animation states
Fixed issues with Waypoint Graphs not working properly
Fixed issues with Priority nodes not working correctly.
To get the newest version go to the RAIN menu in your project and click “Check for Updates” then follow the directions.
Let us know if you have any issues or questions!
-
This topic was modified 2 years ago by Jester.
Sensors have a flag called requireLineOfSight accessible from the UI. When enabled, sensors automatically do the raycast for you and will not include an object in the result if it doesn’t match. There is a sensor match method for matching against and individual RAINAspect.
The RequireLineOfSight property accessor in code was accidentally skipped in the current release, but we have it fixed in the update - which should be available later today.