AI Player Detection and State Graph Transitions

  Рет қаралды 7,923

One Wheel Studio

One Wheel Studio

Күн бұрын

Пікірлер: 62
@nosh247
@nosh247 4 жыл бұрын
Hey @OneWheelStudio i love your tutorials man! i have successfully migrated my complete enemy behavior to bolt in a matter of hours. I have actually implemented a field of view cone port from code to bolt so the enemy only chases you if you are really in front of them. thanks a lot man, keep up the good work.
@OneWheelStudio
@OneWheelStudio 5 жыл бұрын
I'm not sure if I forgot it, or accidently left it out when I edited, but if the NPC won't detect the player. Try adding a "rigidbody" component to the player. It should not use gravity and should be marked "isKinematic." The player object also needs a collider and it needs to be marked "isTrigger."
@zigie
@zigie 4 жыл бұрын
Being a noob, I re-watched your video 3 times and looked at the previous video. I did not see a rigidbody or a collider on the player. It would be cool to have a small tag or pop-up in your video that says to add the missing components or look at the comments for more details. (side note: love your videos and your in-video comments. makes me laugh) =)
@zigie
@zigie 4 жыл бұрын
Missing components for the Player GameObject: Rigidbody: Use Gravity: unchecked Is Kinematic: checked Capsule Collider Setup: Is Trigger: checked Center: X0 Y0.8 Z0 Radius: 0.3 Height: 1.8
@TazkoHoZabit
@TazkoHoZabit 4 жыл бұрын
@@zigie + add a rigidbody in the NPCs Player Detection select Tag "Player" on the Player
@Maetharannell
@Maetharannell 4 жыл бұрын
I figured out that the sphere collider is missing, but didn't think of the rigid body. Thanks for the tip.
@zackhouston7466
@zackhouston7466 4 жыл бұрын
@@TazkoHoZabit Thank You!
@willpace9556
@willpace9556 3 жыл бұрын
Great videos! I'm learning so much thankyou thankyou.
@Visuwyg
@Visuwyg 3 жыл бұрын
Excuse me, I think there is a bug in the "Can See Player" Graph, that causes the NPC to have x-ray vision: The way it is set up in the video, if the ray is cast, the var gets set to true regardless of what tag it hit. After raycasting, the Compare Object and branch should be reversed: That way the ray is cast, THEN the tag check is performed, and IF it hit, the var gets set to true. (It also should be set to false if the ray hit something else)
@PiPiCatStudio
@PiPiCatStudio 4 жыл бұрын
the best tut of bolt!!!
@alejmc
@alejmc 6 жыл бұрын
Awesome vid as usual. These are helping me big time to grasp what can Bolt do. Definitely state machines are for me one of the main pros. Question, coming from a mostly scripting background, the "Player Is Near" and "Can See Player" seem too loosely typed and make me uneasy... is there an easy way to do something more along the lines of broadcast events? Like a flow graph that 'detects' stuff and broadcasts either hierarchy locally or globally. That way the NPC can listen and change state accordingly. For example, it could help to easily expand: "detected resource", "NPC friend has low health", "heard player nearby", "run to point of interest", etc. Those detectors could be all slumped together or on separate game objects (if we need different shapes, visuals, parameters, update rate, etc). It would avoid having to keep track of what variables were assigned and created where.
@OneWheelStudio
@OneWheelStudio 6 жыл бұрын
I right there with you. I don't like how loosely its typed, but I haven't figured out a way around it. Bolt will auto detect object variable names, but seemly only on the same object. Currently Bolt doesn't fully support Unity delegates and events - which is what I tend to use with C#. There are events, but the names of those events are loosely typed as well - so 6 of one and half dozen of another. These events are not broadcast to all objects, but rather you have to tell it what object will receive the event. So in my opinion still of limited usefulness. The developers do have full Unity event support on the development roadmap. I'm looking forward to it!
@MisclickDev
@MisclickDev 4 жыл бұрын
What kind of settings I have to put on the objects to block the sight on view? Currently "Player is Near" and "Can see player" are always the same even I have a wall between them. (My wall is a cube with box collider and right body with freeze position. Also, I put them on "static" as shown in the 1st video from the series).
@Visuwyg
@Visuwyg 3 жыл бұрын
I have the same problem, my NPC appears to have laser vision. It sees the player through solid colliders.
@mikaelsvensson9539
@mikaelsvensson9539 4 жыл бұрын
If you have problem with the "CanSeePlayer" it can be that you missed the "Scene variable Player" he assigned on another tutorial! was in my case. Check his "Top Down camera follow" at 0:30 :)
@Obumbro
@Obumbro 3 жыл бұрын
You are a savior!
@pandarzzz
@pandarzzz 6 жыл бұрын
Thanks for sharing this informative video!
@insomevitya
@insomevitya 3 жыл бұрын
Awesome video! I have one quick question if you do not mind - is there is a way to change the velocity for the bot when they are entering the chase state? I have found "Set Velocity" unit for the nav mesh, but it requires vector, not just a number for the speed, like in the nav mesh agent settings on the object itself. THank you!
@OneWheelStudio
@OneWheelStudio 3 жыл бұрын
I've never directly set the velocity. I would tend to change the speed and let the nav agent do the rest. You could also up the acceleration if you want the speed to change faster. If you really need to change the velocity, you'll need to first change the speed - which is the max speed it can move at - get the velocity, normalize the velocity, multiply it by the new speed the set the velocity to this new value. Not 100% sure that'll work, but that would be my first attempt.
@3po_Orisen_Sithappen
@3po_Orisen_Sithappen 4 жыл бұрын
hi its me 3po m sorry you are way to bezzy just one small question all works fine on wander and chase but if the 2 enemy mobs com in same space while the chase me the get buggy and jiter around confused the can't find the paat to me so the stuck on top of one and the other it takes like about 3 seconds and the untangle and start to chase again what is causing this i can't figure out it must be ray hit ty for all great tutorials
@JkouFiles
@JkouFiles 5 жыл бұрын
My CanSeePlayer flowmacro script on Get variable object isn't detecting my Player Is Near and that unit is red. Is it looking for the Tag "Player"? I attached Player tag to a temporary sphere but it's not changing the boolean.
@OneWheelStudio
@OneWheelStudio 5 жыл бұрын
Any chance I can get you to come over to my discord (discord.onewheelstudio.com)? A screenshot of the flowmacro (while in play mode with the error) could make debugging easier.
@JkouFiles
@JkouFiles 5 жыл бұрын
@@OneWheelStudio sure!
@project1002
@project1002 4 жыл бұрын
I am having a problem with the “Can see player”, my “Player is near” is working fine but my “Can see player” is not working at all. I have add all the ridgiddbodys and collides but it is still not working. I am working on a newer version of bolt so maybe that has something to do with it?
@ranishomali8219
@ranishomali8219 4 жыл бұрын
Have you figured it out?? My CanSeePlayer is always true when tags don't match..
@matxib9274
@matxib9274 4 жыл бұрын
Try putting a "Normalize" node between the Subtracion and the Direction input of the Raycast. Don't know why but just with the subtracion it's giving a wrong direction.
@project1002
@project1002 4 жыл бұрын
@@ranishomali8219 I figured it out. I had only tagged to parent object as ‘player’, you need to also select all the children as well. Hope that helps
@ranishomali8219
@ranishomali8219 4 жыл бұрын
@@matxib9274 @Project100 thank you both so much, the tags were right and I didn't need the normalize. I just needed to add a new branch to compare tag idk why. It was always giving a true because it wasn't comparing tags right yet it was detecting the object colliding well. I'm now stuck on making an edge climb for my game I managed to make one with a character controller but it's not practical do you guys have any tips?? I couldn't find a video on youtube
@tenorgames
@tenorgames 4 жыл бұрын
Good stuff.
@Visuwyg
@Visuwyg 3 жыл бұрын
Another question: my NPC tends to shoot itself into an orbit around the player. It's like a bull fight. How do I mitigate this inertia, and just move straight to the player position?
@OneWheelStudio
@OneWheelStudio 3 жыл бұрын
Yeah that can definitely happen if you try to get too close to the player. You could try targeting a position in front of the player as the target... Or creating a predictive system that based on the position and velocity of the player creates a prediction as to where the player is going and make that a target for the NPC. I don't have a perfect out of the box solution. Sorry. I was basing the project on longer range attacks.
@owsam
@owsam 4 жыл бұрын
My Player Detection flow keeps detecting collider with Terrain not with Player , why does like this? How can I fix?
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
I would check the tags on your objects. Make sure the player is tagged correctly and that the terrain is not tagged "player"
@owsam
@owsam 4 жыл бұрын
@@OneWheelStudio Thank you for the responce! I believe Tags are set fine, Player on Player,Terrain on Terrain. It seems the collider ignoring Player object. I tried to add Rigidbody to player and NPC, also changed the chaped collider shape to detection that detects not Player. Maybe I should try to build all again.
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
Hmm. Sounds like you’ve checked all the basics things. If you can’t figure it out maybe jump on the OWS discord (link in the description) and share a few screenshots - especially of the code while it’s running and or not detecting the player.
@owsam
@owsam 4 жыл бұрын
@@OneWheelStudio I tried to make new player and NPC again and applied same macros, attached Rigidbody and Collider to Player then all worked ok. I found out there were something wrong in my NPC prefab(Maybe I have overwrited it).
@Mark21084
@Mark21084 4 жыл бұрын
Thanks for the informative video’s. Just wondering how would you check if the ‘enemy’ is looking at the player. I noticed it gets flagged as seen even if it’s looking the other way. Thanks in advance!!
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
For that you would need to do some fancier math with a healthy dose of trigonometry. Essentially you would need to compare the vector from the npc to player with the npc’s forward direction and get the angle between those two vectors. Then if that angle is less than some threshold you would know the player is visible and in front of the npc. Not crazy complex but more than fit into the video series. 😀 Does that help? Maybe point you in the right direction?
@Mark21084
@Mark21084 4 жыл бұрын
One Wheel Studio, thanks for the quick response. I would have too experiment. I might just implement it as a visual cone instead of the orb. Check what would be easier 😅
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
@@Mark21084 I had recently seen a video that did something like this, but can't find it now... Good luck. Would be cool to see it if you get it working!
@Mark21084
@Mark21084 4 жыл бұрын
One Wheel Studio when I get it working I’ll add the video reply here, if that’s ok
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
@@Mark21084 Absolutely! Love to see it and a great way to share with folks that might have a similar question.
@arescaelum9251
@arescaelum9251 4 жыл бұрын
This may have been said, but rather than checking the tag on the triggerEnter couldn't you have compared the collider.gameObject to the variable you created for your player in your flow scene?
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
You definitely could. Using tags isn't my favorite method, but it generally works and works in the case where the object isn't stored as a variable OR might be stored as a variable that a certain bit of code can't access.
@MrZero000cool
@MrZero000cool 4 жыл бұрын
Hey, I´m new to Unity and Bolt and your tutorials helped me greatly. I wanted to have some walls to test around with the AI not seeing the player. I placed some Spheres and added a sphere collider to them, however the AI still seem to be able to look through. I tried to enable trigger in the collider but that also didn´t work for me. Any tipps what I could else try or what I´m missing? Thanks for the tutorials! :)
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
Hmm. That is a bit odd. I might try something like a cube and make a wall out of it? Just ensure it's blocking the raycasting. You could also debug the names of the all the objects hit by the raycast. This would help to understand what is or isn't being seen by the NPC.
@antlermind
@antlermind Жыл бұрын
Having a lot of fun with this tutorial! However, I have run into an issue where once the 'Can See Player', and 'Player Is Near' variables are set to true, they never revert back to false. I've watched back through all the videos a few times, and looked over the graphs a bunch, but I cannot find my error. If anyone has run into this and has any tips, please let me know! Thank you :)
@antlermind
@antlermind Жыл бұрын
I figured it out! In the 'DetectPlayerIsNear' graph I never connected the collider on from the 'OnTriggerExit' to 'CompareTag' nodes. Simple fix.
@lers0305
@lers0305 4 жыл бұрын
Got stuck for an hour because I didn't put a rigid body in the NPC T_T but it's all good now
@esneidertafur
@esneidertafur 5 жыл бұрын
Hello, your videos are very useful and thank you so much for learning from them. but I have a problem the player is near does not change the bool. Greetings from Colombia
@OneWheelStudio
@OneWheelStudio 5 жыл бұрын
Can you give me a little more info? Is any of the detection code running? My first suggestion would be to check the tag on the player object?
@esneidertafur
@esneidertafur 5 жыл бұрын
@@OneWheelStudio I guess he ran the CanSeePlayer But not the PlayerIsNear I already checked the label and it's ok
@esneidertafur
@esneidertafur 5 жыл бұрын
@@OneWheelStudio Could you help me by team weaver is that I've been trying to solve it for 2 days and I don't speak much English :C. I just follow your steps in the videos xD And I want to continue with the course :D
@OneWheelStudio
@OneWheelStudio 5 жыл бұрын
@@esneidertafur Does your player have a rigidbody component on it? It needs to not use gravity and should be set to "isKinematic."
@esneidertafur
@esneidertafur 5 жыл бұрын
@@OneWheelStudio No it doesn't have any extra components :C Could you help me by team weaver is that I've been trying to solve it for 2 days and I don't speak much English :C.
@esneidertafur
@esneidertafur 5 жыл бұрын
If you know Spanish, I recommend you to make these same videos.
@OneWheelStudio
@OneWheelStudio 5 жыл бұрын
I wish. Just a ignorant mono-lingual guy here :( I'd be happy to add Spanish captions if someone wanted to write them...
Chasing the Player: AI with Bolt Visual Scripting
4:16
One Wheel Studio
Рет қаралды 12 М.
AI Random Wander
13:19
One Wheel Studio
Рет қаралды 13 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
Saving Data in Bolt Visual Scripting
8:09
One Wheel Studio
Рет қаралды 10 М.
Character Selection with Bolt Visual Scripting - Part 1
8:36
One Wheel Studio
Рет қаралды 11 М.
Making enemy AI detect the player in Unity 2D
12:04
Sunny Valley Studio
Рет қаралды 40 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,4 МЛН
How I Built A LEGO Treadmill That Moves In EVERY Direction
18:06
Banana Gear Studios
Рет қаралды 1,1 МЛН
Clean Code using the Strategy Pattern
12:34
git-amend
Рет қаралды 17 М.
Player Animator Controller - Run and Idle Blending
6:58
One Wheel Studio
Рет қаралды 10 М.
How do non-euclidean games work? | Bitwise
14:19
DigiDigger
Рет қаралды 2,5 МЛН