#🤖┃ai-navigation
1 messages · Page 10 of 1
Hello, can anyone help me with my AI agents? Thery are basicly skipping my triggers when they are not in view... Its so freaking weird, when i open scene view on second monitor they are working fine..
How can I stop a NavMeshAgent from automatically applying its desired velocity (ie moving). I want to apply its desired velocity at fixed time intervals (on fixed update) but if I stop the agent with isStoped = true, it no longer calculates it's desired velocity (it's always zero)
And is there a better way to perform deterministic agent navigation. Right now my agent's finish at slightly different positions/rotations each time I run my simulation. I assume due to frame rate variation
I think you may have to handle that part manually. One way would to do it (and also handle your other problem) would be to use the navmeshagent for pathfinding but handle the actual movement yourself. That would mean you'd lose the automatic obstacle avoidance and things but maybe that's not an issue for your use case
using something like this https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent-path.html
Thanks for the suggestion, although I do need the local avoidance that the NavMeshAgent offers.
I need to find out when DesiredVelocity is updated.
Hi all, i have a 2D game, where a player can "drag" things and these moves may occasion damages. I have a score function based on the total damages inflicted by the enemies.
So i just want to send the Board to the first layer of the Conv Neural Network, and then let the game compute a turn to get the resulting score (to change the DNA of the CNN and the mating probability in accordance to the score)
Since it's a genetic code, i would want to spawn many instances of my game at the same time to accelerate selection.
Are those things possible ?
i'm not sure how these two are related
is your big picture to have a reinforcement learning neural network agent to play the game? i think there is a tutorial for that
but you might be best off trying to solve the game yourself first, to understand if there is a point to that
Hey everyone, does anyone have any idea as to why my agent is reacting to a linker from so far away? i want it to only do the correct jump when its actually on the link or super close
private Vector3 desiredVelocity = Vector3.zero;
private void Awake()
{
agent.updatePosition = false;
agent.updateRotation = false;
}
private void Update()
{
agent.nextPosition = transform.position;
desiredVelocity = agent.desiredVelocity;
}
private void FixedUpdate()
{
// Now we can move here using the desiredVelocity
// I usually zero out the y.
Vector3 velocity = desiredVelocity;
velocity.y = 0.0f;
// Add gravity and stuff then apply to you character controller.
}```
Hello @everyone,
Has anyone work on integrating Dialogflow ES with unity before? I need help please
size of object without AI destination target
size with AI destination target
the scale isnt working properly if this Target is set
if you know the solution please @ me
🤔 maybe it's setting the z component ?
@real sonnet thanks, it was in my script with z yes
https://youtu.be/G9Otw12OUvE
How can I make the agents form like brackeys did and not collide with each other trying to get to the same point?
Let's see how many NavMesh Agents Unity can handle! That's right, another excuse for making a huge simulation ;)
♥ Support Brackeys on Patreon: http://patreon.com/brackeys/
····················································································
♥ Donate: http://brackeys.com/donate/
♥ Subscribe: http://bit.ly/1kMekJV
● Website: h...
several solutions either if one agent and at x distance from the other it slows down, or you make them leave one after the other. Personally the first and much better
Trying to create some flocking behaviour, and getting a little distracted by spirals along the way...
Links and Resources:
Project source: https://github.com/SebLague/Boids/tree/master
Boids paper: http://www.cs.toronto.edu/~dt/siggraph97-course/cwr87/
Points on a sphere: https://stackoverflow.com/a/44164075
Fish shader: https://github.com/albe...
can help you i think
anyone know how to make a enemy shoot at a player in 2d platformer not top down
You can see in the video he uses the obstacle avoidance from the Unity Navmesh (at some around the middle he disables it to squeeze more performance)
I am trying to wrap my head around behavior trees. The whole tree should evaluate almost every tick and not be "stuck" in a state. How do I in practice nog "restart" the action? Say if I when I start moving toward an enemy indicate that with showing the path. I only want to do that one and then run until target is reached .
Or is an action locked for as long as it is running state?
@velvet arrow your node has a status, that can be Inactive, Running, Success and Fail.
I don't think trees walk the whole thing every time.
They keep a list of the running nodes I think.
I started looking at behavior designer and it seem to not traverse if a task is in progress. But you can select priority thus enabling some nodes to re evaluate. Now I just have to figure how to do multiplayer, animation states etc.
No, looking at Behavior Designer.
Ah I see. I am using NodeCanvas.
Yeah, dynamic reevaluation is good for when your nodes have some sort of priority.
Implementing my own feels a bit pointless. I have been trying to decide between NodeCanvas and behavior desigmer
Where if a higher priority is eligible, you want it to interrupt the other ones.
Yes, I mean if I have a patrolling enemy, I want him to abort that if he finds the player for instance
How do you find NodeCanvas? Do you happen to do multiplayer as well. That is my biggest "problem" area atm. The ai logic isn't overly complicated, it would probably be manageable with a FSM but still.
I am using it for a prototype rn and I really like it. Making my own nodes is a breeze. I kinda ignore some features like binding reflected properties and methods and using them as is in the graph. I prefer explicit custom nodes and setting the blackboard values from script.
Also NodeCanvas has FSMs as well.
It supports BT in FSM, BT in BT, FSM in BT and FSM in FSM.
Yeah behavior designer looks more polished for what it does. But having the option for graphical FSM as well is awesome.
As for multiplayer, I don't know. Aren't you supposed to run AI on the server.
Being able to sync the blackboard (multiplayer) and serialize the state(save/load)
Yes AI will be run on server.
Then there is no data to sync?
The transforms for positions. Also stuff like target(who is the enemy targeting, what is the enemy doing)
Well, yes, but that's part of the gameplay script.
So the client can present the data in an accurate way, without being in control
And react to events
I guess I just have to take the plunge and try to implement it, something theorize is too hard :)
So you would recommend NodeCanvas
I guess.
A top down shooter.
2d?
3d.
Cool
I'm curious, how do you handle animations. Do you handle them within the action nodes, have specific ones or totally outside the tree @alpine glacier
I took the principle of "BT states the execution plan, not the execution how to" to heart so nodes don't even contain gameplay logic.
All nodes just submit a request to the AI actor and wait for the MoveCompleted event.
All my nodes are just a bunch of boilerplate, see?
Ah right, animation.
Well actual gameplay logic is contained inside these gameplay SpecialMoves.
And they just call Animator.CrossfadeInFixedTime(SomeSubstate).
This lets you avoid giant spiderwebs of transitions everywhere.
AAA games do it the same way.
Well, some of them.
Instead of every animation substate machine linked to all others you trigger procedural transitions to specific ones from code.
That takes some time to process but sounds really good. Then it is easier to reuse for the player character as wellm
Using real-world examples from Firewatch and Recore, this talk goes through what it takes to make shipping quality animation controllers in Mecanim. It explains how to set up a First-Person character with full body awareness and how the team at Armature set up their AI to work with a variety of body types. It also shows the use of Animation Even...
There we go.
I timestamped it.
Thank you! Do you happen to have any resource regarding "the execution plan"
It's just something I heard.
I don't remember which talk.
Let's put it this way.
If I turn down the update rate of my AI to 1 time per second.
The gameplay will not break.
If I change the animator structure and update the gameplay code, the AI tree will not need to be changed.
This is my first foray into AI.
Yeah I think I get the principle, I will just need to see if I can find myself some examples . To wrap my head around it
I can give you an example of my test tree.
Yes please
Let's look at the charge to node.
It does not trigger animations.
It does not run some movement code in update.
It states that we need to charge to some position.
So it tells the AIActor script hey, this is the position I want you to charge, you handle it.
Just gimme an event so I can signal that the node has completed its work.
I see. It feels like it sort of sets the actor to a specific state (charge state, attack state)
My actors are a bit more loose than that.
Instead of implementing everything in 1 script, each special move is a separate monobehaviour.
I can add the same Charge behaviour to any actor.
It might be dumb to people who actually do AI.
And it can have a totally different charge behavior
Cause my special moves basically replicate how BT nodes work.
To the point that they have a status, enter, exit and update callbacks haha.
But they let me handle special move interruptions on the gameplay side.
That sounds like a statemachine
Well, states are exclusive.
My actions are not.
And well, state machine has fixed transitions.
I see. I think I might make it a little less flexible but still keep more actor specific logic inside the actor itaelf
I don't have any transitions at all.
Well yeah, my system is kinda weird.
I just wanna get this done and minimize my annoyance.
Sure.
I made it this way cause I have no bloody idea what my AI is gonna do in the game.
You can watch Unreal AI tuts for more proper info.
That's a good idea. I will do that
@dusk sandal is it marked as Navigation Static?
Can anyone introduce me to some basic enemy ai that i could try figure out
How do I NavMesh a planet?
How do I clear and rebake a NavMesh via script?
I am making a game that randomly adds or takes walls from the world as you play. It works well for the player since the player uses physics which collides with the walls.
My NavAgent doesn't detect the wall; it uses a NavMesh. When the world changes, he will run through a wall that just appeared or dodge barriers that no longer exist.
I found this thread that askes your exact question. It's a few years old though. https://forum.arongranberg.com/t/navmesh-on-a-spherical-planet/4108/2
Thank you 🌹
Maybe this can help?
https://learn.unity.com/tutorial/runtime-navmesh-generation#5c7f8528edbc2a002053b491
In this recorded live training session we show how to work with Unity’s Navigation tools at runtime. We will explore the publicly available Components for Runtime NavMesh Building and look at how we can use the provided components to create characters which can navigate dynamic environments and walk on arbitrarily rotated surfaces, including ene...
Is there a way to fix this issue? I'm clicking on bottom floor but ai goes to upper floor because my clicked point is closer to upper floor I think?
maybe somehow check the y value of the click and if its below the y value of the second floor it moves it down to 0 or whatever y the first floor is, as to be nearer?
Actually a nice idea, I can check y value but I'm not sure how to set the destination to another y value, I'll try though thanks
I've gotten myself completely in the weeds trying to figure out how to structure my AI so that different agents can share logic. Can anyone offer some tips on structuring them so that things don't become a mess?
For example, I'd like to have agents that can share logic for things like "Attack Move", but may have different implementations, or even different abilities (perhaps one with vision and hearing, one with only vision). Should the agent's brain contain all the logic, so both agents inherit from the same Brain class and modifies it based on what sensory components are attached? Or should each Brain subclass just override functions that can be called from logic stored external to it?
I'm aware there's no "right" answer, just looking for a starting place that won't leave me feeling like I'm making a mess I'll have to clean up later
I thought I had an answer but I still feel like I'm doing something wrong considering I have a gameplay state monobehaviour per each action task type.
And even Unreal tuts don't tell you shit.
Hello. I’m not sure if this is the right channel for this question, but I am trying to develop a set of behaviors for my game’s “enemy” NPC’s (2d top-down game). I want to create a set of weighted averages to have the NPC determine what it should do in a given situation (right now, the options are to stay idle, chase player, run, and/or alert neighbors). I have attributes like proximity of player, aggression level, and fear level, as well as a modifier to cool down times. But I am not sure how to calculate and weight options, without a lot of if…then statements. Is there a way to optimize choices based on weights and a given scenario?
I am looking at using the GOAP model (I'm going through a tutorial now at https://www.udemy.com/course/ai_with_goap) but I wonder if this is the best option? Are there other models that might work for this situation? GOAP seems to be designed for modeling interactions in an environment. For my scenario, I think I am looking for something a little simpler. AI that looks at its environment and reacts based on weighted variables. What other options exist for something like this?
Lol I appreciate the feeling. I talked to someone smarter than me yesterday and settled on something along the lines of
Brainhas functions likeMove()orAttack()that can be called by whatever logic system (BT, FSM, etc) which can be separate or plugged into the brain.- Sensors like
VisionorHealthare each separate components, theBrainhas references to each component.
Good enough to start with.
A behavior tree or state machine would be much simpler to implement, with state machines probably being the simpler of the two as you can just implement it yourself based on a rough conceptual understanding. GOAP and HTN (the more evolved successor to GOAP) are both types of "planning" systems, i.e. for making somewhat longer-term plans.
This is a classic read on behavior trees but note that each node is somewhat more like a "state" than how some behavior tree literature defines nodes (i.e. specific atomic actions). There's a lot of overlap between the two ideas.
An easy way to start would be to just write an update loop for an agent that stands still and attacks enemies, or whatever. Then a different version for the same agent but it only runs away from enemies. Etc. Then write a switch statement so you can toggle which behavior you want at the moment. That's where your "AI" comes in, deciding how and when to switch. You can do it deterministically, randomly, or somewhere in between, but that will give you something to start experimenting with.
That's nice. Having sensors separated and reusable is good. You can even tick those sensors in different frame rates...like "Only update de eyes at every 15 frames", so you can do expensive operations (like raycasting for FoV and overlapping) in a reduced interval, depending on how frequent your AI needs the data to be updated (and depending on the amount of agents and complexity of the sensors to get the data)
Having a Brain is also ok...but I prefer polymorphic and "generic" solutions. I prefer that the FSM or BT will expect some kind of Action, which might have an abstract Execute method. Then you create N actions which inherit from Action, and just implement that Action's specific logic...like ActionChaseEnemy.Execute() would move the entity towards a target, ActionHealSelf.Execute() would use a health pack, etc. So the BT/FSM will just rely on the generic Action, and you can create, plug/unplug new types of Actions as you want. But I prefer this approach being data-driven, so you can just reference different Action assets and that's it, you changed how your AI behaves. Having it all in mono behaviours will make you need those may components on all of your Bots, creating may instances of Brain, which is not very optimal depending on the amount of data that it needs per instance. But it is not bad. It's just per user preference...I always do it data-driven
I want to create a set of weighted averages to have the NPC determine what it should do in a given situation
That's the headline for the Utility Theory model. You haveConsiderations, which will result in aScorebased on some Input, which are inserted into Curves. You re-evaluate these Considerations every tick and score them from best to worst. The Score itself is the utility of that Consideration. It is like:
- "How useful is it for me to Heal right now?" SCORE: 0.7
- "How useful is it for me to punch my enemy right now?" SCORE: 0.25
- Healing gets higher score. Do it
It's not the simplest AI model out there...but yeah, if you want weighted based priorities and decision making, that's it. I'll post here some links of GDC talks on the matter that you can watch in order, if you really wanna go in deep on this:
GDC 2010: https://www.gdcvault.com/play/1012410/Improving-AI-Decision-Modeling-Through
GDC 2012: https://gdcvault.com/play/1015683/Embracing-the-Dark-Art-of
GDC 2013: https://www.gdcvault.com/play/1018040/Architecture-Tricks-Managing-Behaviors-in
GDC 2015: https://www.gdcvault.com/play/1021848/Building-a-Better-Centaur-AI
GDC 2018: https://www.youtube.com/watch?v=TCf1GdRrerw&ab_channel=GDC
PS: Utility choice (weighted decisions) can be just part of other AI models no problem...like having a BT, HFSM or GOAP which uses the core idea of scoring, in order to make the decisions and drive through states/branches/whatever
Yeah you don't HAVE TO implement Utility theory to benefit from weighted scorers. They are self-sufficient.
@sonic rain how do you separate gameplay from those actions then? Let's say an attack action needs to play an animation and wait for it to end and a bunch of other stuff like changing movement speed, for example.
Yeah this is kind of what I was getting hung up on. I have a tendency toward pre-optimizing and also making my systems overly generic as if I was going to give them to a designer who's goals I don't know. But I'm the designer! So I end up falling into the trap of spending six months building the perfect system, and then being left with a design that could be implemented by two if statements. For this specifically I realized that (part of) my issue was not having the design nailed down, so I spent a lot of time figuring out behavior trees and then realizing that what I actually need was a planning model, and I was working the problem from the ground up, trying to figure out how my high-level behavior trees will handle atomic actions which shouldn't even be part of them.
The data-driven part specifically is where I got hung up on code structure. The .Execute() would need to have references to what's using it, so I wasn't sure where that should go. Questions like "What happens if you call Move.Execute() on an agent that can't move" and "Am I going to be wasting time doing GetComponent every time I call any function" were really tripping me up. In reality, it's no trouble to just override a few functions for the one or two agent types that will vary slightly from the base class. (In this particular case)
Great, thanks for that! I will work through those videos. I will also look to see if there are any online tutorial/course on this (if you know of any)
Putting those parameters in the tree itself would be bad cause then if you wanna do the same in a different part of the tree, ya gotta duplicate.
I ended up having to replicate the actions but on the gameplay side.
So I have a MoveToObject action task that just calls AIRequestId requestId = actor.Execute(actor.GetComponent<MoveTo>()).
My actions can perform changes to the game state (i.e moving an agent, attacking, healing, storing a reference to somebody that I wanna chase). I don't couple animation to my AI, nor do I couple specific ways for doing stuff. I do atomic stuff, like micro actions which can perform small (or not always so small) stuff, and I have the other key part of the AI, which are the transitions. The transitions happen only when certain (set of) conditions happen. So the "completeness" of something is defined by "did the things specified by the transition happen?". Then I model the entire behaviour based on that:
- While in a state, keep doing actions (which doesn't return nothing, they just execute stuff)
- While in a state, keep checking for the transitions (conditions) which comes from that current state
Letting type-specific components handle everything related to some task is fine too, if I understood what you're doing. But it's less re-usable (IMO), and is way more coupled. It probably ends up depending a lot on that specific entity and task in hand, and that specific game, etc...if a MoveTo fails for some reason, then you'll have to investigate the whole things that MoveTo does, which can be a spaghetti. It is a coder choice, if it suits your case, that's very cool!
I have 4 AI models implemented in the same framework, and they all rely on abstract Action. I made one sample test game (very simple: a guy who picks jewels in the scenario and deliver them into a box), and in all 4 models I used exactly the same Actions. The reusability is nice. But not all project needs that! So in the end it is a matter of choice and not only "correctness". I'm interested in the way that you seem to do your AI, and I think I'll try playing with that too, but so far I'm following that path
I actually made it that way so I can reuse same actions on all AI.
Yes it is reusable, I'm just not sure if it ends creating too big/spaghetti dependencies
If you create type-specific components to solve a problem in its entirety
Doesn't seem to allow for easily changing how a big task needs to be done
Seems like it needs to increase and change MoveTo a lot if needed
Rather than just re-referencing some atomic actions
I might be wrong ofc
Well, there will only be 1 move to. There weill be other behaviours like strafe, follow that impact steering.
For example, here's how the charge attack component looks.
How would you do it without making a base actor class that supports literally everything?
As for referencing:
- The
abstract Executecan have some parameters (if it's data driven, this is mandatory), such as the character itself. So it receives "character" as parameter, and performs stuff on it - It can have a
Contextobject which you fulfil with data, or references to components, which are already pre-cached so you don't have toGetComponentfrequently
So it would be a matter of pre-caching, and parametrizing the Execute with the types of data that you need
But yes it can be challenging sometimes to get the data needed...you might here and there have troubles on doing so. I see many devs talking about using Context objects which are passed down the pipeling, etc...but also, it can be a good thing for the AI to not have access to everything, because you know, encapsulation and decoupling is a good thing too
It is also very very common to see AI devs with blackboard systems implemented (a global blackboard for shared data, and a per-entity blackboard for entity-specific data, like that entity's health). Then you get data from the blackboard
So yeah your concern is real and a common thing
That look cool. But yeah the way that I usually go for it is not mixing too many systems into one's hand. You have damage, speed and animation, there are at least three systems involved, which can be messy. If your only have 1 of each type of things, that's fine, but what if you have a BullCharge, GoatCharge, LionCharge, etc...it's a big Ctrl+C / Ctrl+V, where each one of the Charge types would have micro-specific changes depending on how an entity can charge somebody, did I understand it correctly?
My example is assuming that the ways to Charge would be different
A non-optimal case
For a large scale game
No. They would use the same component. You'd just set the animation names in the inspector.
I don't mean the animation
And the damage and the speed multiplier.
Lets say that one will Charge in a straight line, other would Charge in a senoidal movement
And other jumps
That's a big switch case inside the component, no?
For jumping that'd definitely be a separate component.
As for the path shape, sure I could just add an enum dropdown.
Yes, so that's the big switch case based on an enum that I personally don't like, but I understand how useful it can be
I'm just not sure how it scales for huge projects
Hey, MonHun devs do it so yeet.
Interesting
So you would prefer to use a sequence to implement this task?
Basically hack it as a visual programming tool?
If the Charge component itself can be break down into minor responsibilities, I'd say that's cool, and now I can see it better as you explained me how you did it. I'll try it myself this year to get a deeper look
Uhm it's not broken down.
Yes, I would have an HFSM with the Charge behaviour completely defind in micro-states with micro-actions. It can be done neatly because of the H (hierarchical). I could then tweak every detail on it in the Charge sub-state machine
Everything that I'm saying is based on the visual programming tool that I have
But then you'd have to specify the running speed in the tree itself?
It is (IMO) the way that desingers can do the job with the coder: by having a sub-set of Actions that can be mounted in any way, compiled into a data asset, run the game. If everything on the AI is 100% defined inside a component, a non-technical designer will not be able to handle it, designers will just say "hey coder, I want THIS. Oh, that went bad...nah, now I want THIS"
Which can be a huge waste of time on quick production
I'm inspired also by Square Enix' HFSM+BT editor
Hm. But you can't really handle interruptions as gracefully if you code gameplay in the tree.
I'm not sure if I follow
Let's say you use a sequence and in that sequence you use an action SetTarget. And at the end of the action you put ClearTarget. But if some action higher in the tree interrupts the sequence, you don't get cleanup.
You got invalid state.
I am using NodeCanvas which has both BT and FSM btw.
Well but that's BT implementation specific ain't it?
I do reactive BT
Unreal style
NodeCanvas seem nice, never used it
But I consider, seems very cool
You mean your node graph has an event slot you can connect and hook cleanup up to it?
Not necessarily, it's the whole concept which wraps "event driven BTs", the core idea being "cache the Running leaf and re-evaluate only Dynamic Composites, Observed Blackboard Entries" and yes it is possible to do Events. It's a large topic which some of us talked about here: #🤖┃ai-navigation message
Just to be clear, I have things divided into atomic stuff, so I can have my AI editors, so it enforces decoupling/non spaghetti, and helps designers to have the power to change the resulting behaviour, which is the main point that I think that cannot be done with hard-coded behaviours on Components that designers cannot touch, only the coders. It's all atomic, data-driven, zero allocation, leightweight, designers can participate
Hey @alpine glacier I have to go, nice talking to you, I will try your approach some time for sure
Talk to you later, bye bye!
Alright.
Hey, so in order to get the job i applied for i have been given a demo project and one of the tasks is creating bots in a single player game.
So this game is kinda like Aquapark.io and they asked me a build an ai for the bots that some fails to complete the tasks the in game some doesn’t, as if they were not bots but players. Duhh.. :P
The thing is i am not sure how should i make my research about this to create such an ai. I have practiced ai before but those were for games like tic tac toe.
Can anyone let me know what kind of ai mechanics i should use or even some keywords to get me start researching about this?
Whatever the AI you always want to implement some kind of handicap. Because once you figured out - or get enough closed to - the perfect version of your algorithm/decision-making system, your bots will unrelentingly perform at 100%.
Think about preventing your first person shooter bot from scoring 100% headshots hits
Or closer to your tic-tact-toe game, forbid your chess AI to always win in the shorter amount of moves possible
Maybe you wanna explore randomness or percent-based modifiers to your equations
You can also limit information available in your AI blackboard
(making sure your AI is dumb)
Thank you i will check it out
I'm looking for a way to create an AI with 100 percent accuracy. Well it will always shoot the projectile towards where the player would be based on the velocity.
As long as the player doesnt change their velocity they will get hit
How can I lead my AI's shot? I am currently doing newPlayerPosition = player.transform.position + ((Vector3) player.movementInput * speed) but the AI leads it too far and can easily be dodged.
Projectile travel time needs to be accounted for
Is there a way of making a navmesh system without baking?
Anybody know if there is a way to bake a navmeshsurface only above a certain height, or within a boundary area?
@near tulip you can do runtime navmeshes
Try setting your surface's Collect Objects property to Volume
Thanks a million
im figuring out behavior trees (self implemented as its just for learning purposes)
currently i want to implement basic
-if sees player, move to player position
-when player is lost, wait some time
- wander randomly between waypoints
im stuck on the middle part as i cant figure out what kind of nodes i would need to trigger it only once when the player was just lost and not everytime it doesnt see a player
would this even be handled directly via nodes or would i just set a variable when setting the player to null, which the ai can check, wait and then remove that variable, to not trigger the wait behaviour again?
I think it can be called using priorities in a sequences. Which can force re-evaluations if a previous condition has been changed. NodeCanvas calls it "dynamic". And the waiting action should return "running" until it is finished, not really re-evaluating the whole tree each tick.
can anyone point me in the right direction. Wanted to see which type of AI could be suitable for this type of game. The goal is simply to push the opponent off the board. And the input(controll) is a force in x,z direction. No ground-breaking neural network, something simple 🙂
i tried to wrap my hear around that but still cant see it working
if i have a sequence with:
sees player -> moves to player -> waits
then that would only wait after the move node succeeded
i dont see a way to get it to wait directly after it looses sight of the player as what would fail there is "sees playerr" but i dont want it to wait everytime it doesnt see the player, just directly after loosing sight
to be fair, I would probably have solved it using an interrupt and changed the whole behaviour tree. I have 1 tree for trying to find player and 1 for what to do if player has been found.
can you roughly tell what the order would be there?
im totally still at the beginning of learning about bt and while i want to implement it myself to learn im totally open to examples of how to properly use it
sorry I am merely a beginner myself. It depends a bit on the implementation of the behaviour tree itself.
But interrupt or dynamic /priorities is what you should look into
ok ty
Hey guys
You ever ran into a problem
where you're building a NavMesh, but its never making any progress at all. It just sits there loading forever
This is all thats in my scene
https://gyazo.com/818e72b20d2ce479feb462b7819e5f47 I want to remove the foreach loop and instead add GameObject.FindGameObjectWithTag("Enemy") how do I set the .patrolpath to it?
Hey guys, I tried creating a new project, and nav mesh baking worked perfectly fine, but the version was 2020.2f.2
while in my current project thats 2020.2.7f can't bake nav mesh
why...
why is it trying to get through that
thats a solid object
it doesnt try to get through other solid objects
just that specifically
now its just infinitely stuck there
and thats game breaking
because the character is vital for the game to function properly
perhaps because it has holes or smth
idk
make sure it is not using old data or an alternative mesh somehow.
or agent data changed and mesh not recalculated
i baked it again but it still didnt work
idk tbh
it has a box collider, should that not be enough
hm...
i ticked off not walkable and now he appears to be getting around it but im just gonna let it run for a while and see if he gets stuck
(he's programmed to randomly wander around the map so if the bug is still there after a while it will happen)
oof
i think nav mesh is kinda broken
Resolving an unexplainable behavior helps re-creating in clean environment, in new scene, for example (with more basic components). Then comparing what went wrong.
i think im just going to reset his destination if his position is the same for longer than 5 seconds or something tbh
seems like an easy, lazy fix i can do
On other hand if you don't fix this, it's likely you'll encounter it again by repeating the same mistake. Mesh should be working fine when configured properly.
hold on a second
ok so basically: im stupid, one of his possible destinations was inside the shelf
lol
i removed the shelf and then he went in that same spot and i was like wait hold on a second
need some help deciding what kind of AI algorithm I want to use, I want my AI to not be too predictable and be reactive to the environment / player, (i want to have high replayability), not sure if i should go with BT, GOAPs or something else pls @ me
how do i make a person that chases u?
Hey guys, i have this script where bots move and stop when the distance between them and the target is 1, problem is its a wave game and the enemies have collision and as soon as any of them collides with each other they all start shaking trying to get past that 1 range barrier 😄
I can post the code just ask I don't wanna overlap any other questions
navmesh agent + animations
is it 3D or 2D @ivory rock
3D
use navmesh agent and then just sync animations to the movement speed
How do I make real time navigation for a 2d environment? I have a randomly generated world and I’m struggling to get the enemy to path to the player properly
is it possible to recaculate a certain area of a navmesh?
for example: I want destroyable trees
and I want to update that in the navmesh
but I dont wnat to update it completly due to map size
As far as I am aware it’s all pre baked and that is my problem too
@patent mirage @pearl temple
Thanks I’ll give it a look 👍
for things like your tree this might also work?
https://docs.unity3d.com/ScriptReference/AI.NavMeshObstacle.html
One of my navmesh obstacles is carving out the navmesh like it should, except that the carving area is larger than I want it to. It seems to be take the carving size from one of the children to this navmesh obstacle, which happens to be a collider. This collider's size fits perfectly with the carving size. But I want it to carve from the navmesh obstacle collider size, not this child collider. Anyone know a fix?
Why is the child collider there then? Child colliders are considered a part of any parent collider
its a trigger collider, made for detecting when some other objects get near it
used for other purposes than 'collision'
So it seems that the carving's size is automatically the size of the largest collider of the gameobject, including child colliders..? Any way to turn this off?
All child colliders are combined into the parent collider. I think for this you'll need your trigger on a different object
Or at least not below other colliders or rigids in it's hierarchy, otherwise it will be assigned to them
I was afraid of that. But should be fixable. Thanks for your help
No problem. Yeah it works the way it does so that a "compound collider" can be made from several simple primitive colliders
@thorn hemlock you could also try moving the colliders to different layers? May also work, though I'm not 100% sure
I think the first solution is the one most likely to work. Yeah, i suppose that makes sense, just wish there was an option to disable that.
@marsh sundial I like your keyboard
@patent mirage haha, thanks. WASD brand, had it a few years now
Hey there, how can I make my enemy able to drop heights when pursuing my player?
I currently have this set up, whenever the player drops from that ledge, the enemy awkwardly goes back down and around.
You need an off-mesh link
no
11 days ago he said this... his computer is just that slow
11 days later he will have a witty response to my witty response
@twilit saddle 🙏
how should i consider scripting an NPC? Is it wisest to hold most of the code in a single script? should i do a separate script for its movement? Same as heath? abilites? I'm just looking for recommended coding practices for NPCs
hey guys , anyone have an idea on how to make an top down 2d enemy ai move in an area rectangular (minX,minY,maxX,maxY)
i have this script still i dont know how to add it to it
ai wont update its path
Sounds like your IsDone never returns true
I'm currently using a DrawLine to check if my enemy has line of sight of the player in order to move toward them, however it gets stuck in corners sometimes. Is there another way to check for vision, possibly a thicker raycast?
BoxCast, SphereCast, CapsuleCast
Does anyone know how NavMeshAgent and NavMeshAgent.areaMask works?
I want to change the areaMask via script
has anyone implemented utility theory
probably, but as everywhere else https://dontasktoask.com
is there a way to smooth the path of a navmesh agent ?
currently its like this but i want it to be a more bezier curve kinda thing
What's a good approach to pathfinding with things like locked doors? For example, there's a bunch of keys, some behind locked doors, and I want to collect all of them in the most efficient way possible. Trying to do a branching kind of A* where it starts a new branch every time there is more than one key available is getting to be a bit of a mess.
What's the biggest size feasible navmesh?
I'm not asking just to ask though
I watched the GDC talk: https://www.gdcvault.com/play/1012410/Improving-AI-Decision-Modeling-Through
at the time I was looking for any existing tools based on AnimationCurve that could be used to generate utility scores
settled on DecisionFlex https://assetstore.unity.com/packages/tools/ai/decisionflex-8967
Behavior Designer has Utility Theory in it as well
but I dont like visual scripting
Hi all, I'm using NodeCanvas right now for AI to do behavior trees and FSMs. But I feel like it's overly complicated. Even just trying to reuse logic across assets and bind animators and stuff, it's messy.
Am I overthinking it? Should I just be using code or some other framework?
I don't have crazy complex AI needs.
yeah nevermind, I'm gunna scrap NodeCanvas and just do this in code
Does anyone have experience using ML to develop AI and playtest their games?
I found this article online and I have a bit of experience with ML so I was eager to see how easy this is to do https://ai.googleblog.com/2021/03/leveraging-machine-learning-for-game.html
Unfortunately the article is sparse on details
I'm not sure but I think ML is typically too computationally expensive to actually do anything at runtime. But it's great for stuff that finishes executing at compile time. In my case it's sometimes useful for art production. Surely it can be used for creating data structures like graphs, which can then be used at runtime. but again i am a newbie at it and I'm sure there are many people here who know more. )
the article you linked is pretty cool, looks like they got it running great in realtime. i'd like to know more too ))
Is it safe to add rigidbody and collider to a navmesh agent?
Apparently its not, my character went crazy after adding rigidbody...
The game I'm working on is turn based like the one in the article so runtime shouldn't be that problematic
My main concern is how to encode the game state and translate the output to a decision
Plus how easy it'd be to train
wdym my computer is fast
Omg so fast what did you get a new cpu?
Does anyone know of a workaround for this?
https://answers.unity.com/questions/1523558/view.html
I've found six other posts asking the same question with no solutions unfortunately
hey y'all!! i got few questions about AI.. tbh i got many questions cuz i am very new to AI things. First question is, i created a state machine to control my "npc's". I want to make it very simple, find a target, go to a target, attack the target. what are the best practises for it? like, should i use navmesh and agents or should i just go for something else.. im really lost here 😄
Wassup, whenever i build a navmesh in code using NavMeshSurfaceVar.buildNavMesh();
the game freezes for a couple of seconds and then my agent freezes
and doesnt walk around
@chrome surge If you're doing that in the middle of a frame that doesn't sound surprising. I'm not really familiar with this API, but wouldn't you need to call some Async version?
Aha, what wierd about my problem is that, yesterday i launched unity, the day before everything worked fine, but then it started freezing, i changed apsolutely nothing but now its freezing
thinking about completely removing all of the nav mesh stuff i have and reinstalling all of it,
Well, I have no idea what might've changed, but if you think about it it's likely that building a structure like that can't be done fast enough for a single frame
Yeah maybe, used to work fine but now it just freezes and breaks the agent lmao
They do seem to have APIs for this: https://docs.unity3d.com/ScriptReference/AI.NavMeshBuilder.UpdateNavMeshDataAsync.html
Again I'm not sure if that's quite right as I've never used it myself
oh ok il check this out
for updating the NavMesh at runtime you wanna be doing NavMeshSurfaceVar.UpdateNavMesh(NavMeshSurfaceVar.navMeshData)
yeah looking into it rn, im doing that but now when it updates it deletes all of the area of which the agent can walk,
i think this also happenened for the buildnavmesh too but atleast it isnt freezing when i do this method
its almost like its removing the data
I use navmesh agent to make enemies walk towards the player, when the player is inside a collider they start attacking and I want the stopping distance of the enemies to be there
now either they stop too far away or walk inside the player
any tips?
Your reusable logic or animation management shouldn't be in AI graphs at all.
@dusk sandal you can update your navmesh target at fixed interval.
Let's say every 0.5 seconds or so.
Also you can always throw the navmesh agent away and write your own with your own logic for steering.
I'm trying to make my nav mesh spawn not in 0, 0 and its giving me this error
How would I fix this with it not spawning in 0, 0
is the free version of a* project worth using
Heya everyone! I'm using A* to attempt to create wandering AI, where the AI will go to a randomly generated position, then when it reaches that one, go to another.
Unfortunately, I'm quite new to A*. I have a simple target system working where the AI will go towards a target, but not to a randomly generated position. Anyone have any ideas?
One way of doing it could be this https://docs.unity3d.com/ScriptReference/Random-insideUnitSphere.html
That's just a random idea though, depends a lot on your game
I just saw this, and I'm about to see how it goes 😃
Use insideUnitCircle to get a 2d vector as a direction and then just set their destination to (position+direction)*someDistance (or the closest point found in your navigable area). If you use a vector3 for a 2d space, you'll get vectors of random lengths when you discard the 3rd dimension
I want to develop a AI for a card game do you have docs or exemples ?
@civic jay https://www.youtube.com/watch?v=cfXDwZ7PAQk&list=PLOoQ0JTWjALRfF1bxt2-wRrG4PVezL37b maybe this help you
#Unity #CardGame #Tutorial
How to Make Card Game
AI System
(Graphics & Source Code)
PATREON ~ https://www.patreon.com/cezarysharp ~ PATREON
Cezary Sharp Fanpage: https://www.facebook.com/CezarySharpOfficial/
Cezary Sharp Pinterest: https://www.pinterest.com/cezarysharp/
Thanks
I will try to not copy all 😂
private void Patroling()
{
if (!walkPointSet) SearchWalkPoint();
if (walkPointSet)
agent.SetDestination(walkPoint);
Vector3 distanceToWalkPoint = transform.position - walkPoint;
//Walkpoint reached
if (distanceToWalkPoint.magnitude < 1f)
walkPointSet = false;
print("Walkpoint is false");
//Mike's Experimental Code
}
I have this set up, but when the agent reaches its target destination, it just stays where it is. I don't know why
there has to be an issue with SearchWalkPoint, maybe picking the same destination?
Ill take a look
private void SearchWalkPoint()
{
//Calculate random point in range
float randomZ = Random.Range(-walkPointRange, walkPointRange);
float randomX = Random.Range(-walkPointRange, walkPointRange);
walkPoint = new Vector3(transform.position.x + randomX, transform.position.y, transform.position.z + randomZ);
if (Physics.Raycast(walkPoint, -transform.up, 2f, whatIsGround))
{
walkPointSet = true;
}
}```
I have this set up for searchwalkpoint
I believe that raycast should be inverted, you want it to set walkPointSet true when it doesn't hit something
oh, should I just change it to walkPointSet = false then?
no add a ! before the raycast
oh I now see what they raycast is for
Yeah
I can put in the whole script if that helps
like the movement bit
The main problem that I need to fix is that I need it to identify that it's not moving anymore, therefore, find a new waypoint
but the way i have it set up isnt doing that for some reason
so it works once, but thats it?
correct
Only thing I would suggest is manually setting the walkpoint for testing
Mkay, will do
or throw a bunch of debug logs on it to see exactly what is happening
So changing it manually works fine
SO I just need to find a way to change it when it stops moving
Is there a way to calculate the velocity of the gameobject/rigidbody? I've tried rigidbody.velocity.magnitude but it doesnt compute
so its an issue with SearchWalkPoint
I believe so
It works fine the first time, but once it reaches its destination, it doesnt calculate a new one
is the random range large enough? if its 1 or less it'll keep giving locations less that 1f away and have to check again
also what is the issue with rigidbody.velocity.magnitude?
I have the WalkPointRange at 10, i've tried at 30, 80, and 100, and it all works fine
Ill show you in a sec but
Vector3 distanceToWalkPoint = transform.position - walkPoint;
//Walkpoint reached
if (distanceToWalkPoint.magnitude <= 1.0f)
walkPointSet = false;```
I have this, is it maybe the fact that it's trying to get 1 magnitude value out of a Vector3 value?
Like there's 3 values, and it's trying to return one
no magnitude gets the total length of the vector
I would just use Vector3.distance(a,b) btw
rigidbody.velocity.magnitude returns:
Error CS0246: The type or namespace name could not be found?
&
"rigidbody.velocity" in explicit interface declaration is not an interface
how would I use that? Like where would I replace it
are you literally typing rigidbody or the cached rigidbody field?
you need to make a field for Rigidbody rb; and use GetComponent<Rigidbody>() in awake
ohhh thank you
or make it public and manually set it in the inspector
no problem
basically you need to tell it specifically which rigidbody you want to know the velocity of
I'm curious to see the movement code now
ill show you once im finished with this bit
Okay, so I got it so that when the velocity is below 1, it finds a new one, but the problem is now that, since it starts at 0, it constantly is finding new ones and trying to move towards them
how are you moving the rigidbody? unless you use Rigidbody.MovePosition it won't update the velocity of the rigidbody
private void Patroling()
{
if (!walkPointSet) SearchWalkPoint();
if (walkPointSet)
agent.SetDestination(walkPoint);
Vector3 distanceToWalkPoint = transform.position - walkPoint;
//Walkpoint reached
if (distanceToWalkPoint.magnitude <= 1.0f)
walkPointSet = false;
//Mike's RB Code
if (rb.velocity.magnitude <= 0.3f)
{
print("rb.velocity.magnitude is lower than 1");
}
}
private void SearchWalkPoint()
{
//Calculate random point in range
float randomZ = Random.Range(-walkPointRange, walkPointRange);
float randomX = Random.Range(-walkPointRange, walkPointRange);
walkPoint = new Vector3(transform.position.x + randomX, transform.position.y, transform.position.z + randomZ);
if (Physics.Raycast(walkPoint, -transform.up, 2f, whatIsGround))
walkPointSet = true;
}```
This is the movement code
I need to see how the actual character moves
I can show a video hold on
I assume agent.SetDestination() is in charge of that
Oh wait u mean the code lol hang on
yeah sorry lol
no worries
agent.SetDestination(walkPoint);```
Yeah this line
this is for an enemy ai btw, just to be clear
can you show me the code for that?
in visual studio right click on SetDestination and click goto definition
I'm just confused because I don't see any code that actually moves the enemy
are you using some asset to handle character movement?
it's using the navmeshagent, so the agent's destination is set to the walkpoint which automatically moves it
oh okay
I'm not too experienced with navmesh, but you said it worked fine when you manually set the destination
correct
im just trying to find a way to set it to false once it reaches it
would there be a way to determine if it has reached the walkpoint?
put debug.log messages on everything and see what is happening
alright
I think ill call it a night for now, you really have been helpful. It's getting late for me so ill sleep on it and come back once i am ready again
ill try some other methods but thank you so much!
like if (distanceToWalkPoint.magnitude <= 1.0f) walkPointSet = false; Debug.log(distanceToWalkPoint.magnitude); Debug.log(walkPointSet);
no problem, good luck
Anyone have experience with nav mesh surface? I'm trying to solve a problem where building my nav mesh results in flat areas under hills being navigable. We're building dirt paths by clipping in thin cubes of dirt at the bottom of hills. Hoping there's an alternative to "carving" each path by hand.
sounds like this might help
https://assetstore.unity.com/packages/tools/ai/navmesh-cleaner-151501
we're using it in our current project & it's great
I should mention that the PointInTriangle function it uses to determine which areas not to 'clean' doesn't actually work in all scenarios, so I swapped it out for this
{
var plane = new Plane(v1, v2, v3);
if (plane.GetDistanceToPoint(p) > 0.001f)
{
return false;
}
var tN = plane.normal;
plane.SetNormalAndPosition(Vector3.Cross((v2 - v1).normalized, tN), v1);
if (plane.GetSide(p))
{
return false;
}
plane.SetNormalAndPosition(Vector3.Cross((v3 - v2).normalized, tN), v2);
if (plane.GetSide(p))
{
return false;
}
plane.SetNormalAndPosition(Vector3.Cross((v1 - v3).normalized, tN), v3);
if (plane.GetSide(p))
{
return false;
}
return true;
}```
probably not the fastest way to do it but fixed the problems I was having
Hey guys. I've worked with MiniMax in the past but never MCTS. I'm now understanding it for the first time and I'm a bit surprised by how it works. It seems pretty imprecise for how popular it is. Does anyone with experience know how to tell when it should be used over the former?
The branching factor for my game is pretty high but a lot of the branches don't yield impactful results. This is why I looked into MCTS in the first place.
Anyone ever get 'Failed to create agent because it is not close enough to the NavMesh'?
Yea it's not uncommon. Make sure it's on a navmesh when the agent is enabled and that the scale of your world is not too far off from 1 meter = 1 unit
thanks @molten sequoia how do i check my world space? sorry new to this..
The 3D object cube is 1 unit big in all directions
If a dog in your world is massively bigger or smaller than that, your units might be a bit bonkers
a cube looks fine.. the weird thing is my other navagent works fine.. guess i'll just keep my mushroom guy with same movements as a worlf until i figure this out, any other tips? @molten sequoia
when you say on a nav mesh, you mean position the gameobject on my baked floor right?
Yes
ah got it working.. seems like the base offset needed to be changed, it was up in the air rather than on the ground 🙂
thanks so much!
hey so I have a problem with my AI enemies: when the player is on a section of the navmesh that is not accessible to the AI, it stops moving or behaves weirdly. I want them to move as close as they can and so that I can eventually make them jump or drop down.
Generally you should at least get a partial path
If the navigation system panics, you could try first calling the whatever methods snaps to the navmesh and navigating to that
I think I may have solved it by changing some settings in the navmesh baker
nope, nevermind
it seems like the problem only occurs with multiple enemies for some reason
if there's only one, it works perfectly
Hi all im using raycast over an enemy and i have my player and all is suppost to be working perfectly
but my enemys are not following the player.
Anyone has time to check it out?
but my enemys are not following the player.
Yep I got a ryzen 69
Dayum thats amazing bro Looks like you lagged for a bit tho
Im trying to bake a navmesh agent but why doesn't my new map getting baked?
@sleek jacinth Don't crosspost.
Hello everyone, do you know if there are some tutorials about ml-agent with self play?? Because i don't understand how it works with teams...
And what kind of information does Ray perception sensor 3D gives for observation?
Hi, is it possible to manually move a navmesh agent's perceived position to where the object's transform currently is? I'm trying to do a jump animation using DOTween with a navmesh agent, but if the agent jumps past this gap, he snaps back to where he last left off, even though I'm using agent.nextposition and setting it equal to his end destination.
Is this even possible?
The agent also does the same even if there is a navmesh link between the gap. It seems to not want to cross it at all.
Hey, does anyone have a picture of a very large behavior tree I can use for reference? I don't need read what it actually does, I just want a picture of a huge tree
Have anyone tried making a smooth agent transition between neighboring navmesh chunks over navmesh links ?
Even with very short navmesh links (.0002 units) the transition is still snappy. Just 1 or 2 frames, but still noticeable.
what would be the best way to make a path finding ai in a random generated world
Heya everyone! Using A* on a top down grid map, and I'm struggling to figure out why some navigational areas appear in walls, despite them having been set as an obstacle?
The only way to fix itself is to set the node size to 1 (instead of 0.5), but doing that makes the entrance unable to be accessed. Any ideas?
hi all
Guys, please tell me how can I make automatic people so that they can walk by themselves?
2d isometric
um i trying to make enemy that shoot u in 3d game plz help
Can anyone recommend me a free "library/framework" with the GOAP implementation?
I've found some of them over git/unity store, but wanted to check if anyone can recommend a good one
Has anyone setup A* that makes use of memory instead of world information?
Something like:
Agent stores its own walkableGraph and they update portions of the graph with what they can currently see.
The intent being that if a wall is created outside of their view, they would create a bad path and follow it until they see the new wall and update their walkableGraph.
Not free or GOAP, but DecisionFlex is an excellent Utility AI tool
I want to learn how to create bots for games in Unity. Does anyone have any idea about this topic?
Depends on your goal.
A method that I like is behaviors and goals.
Actually kinda similar to ecs model.
There is a common goal that the behaviours operate on.
So the goal (component) could be a weighted list with various behaviours (systems) that alter the current weights.
Then you have a final system reads the goal and acts to accomplish it.
Isn't this something you can do with NavMesh Components?
IIRC you can tell it create a navmesh within a radius of the agent
I haven't done pathfinding in unity before, so maybe?
do you know how it handles navigating to a point outside of that radius?
because I would like the agent to still path smartly around what it thinks is there
No idea. Haven't used Unity pathfinding for a while.
You can manually control what to use as source geometry to build a navmesh at runtime, but I'm pretty sure it won't scale all that well
Yea ... I'm probably going to have to set it up manually instead of using something that is prepackaged.
This game object has no colliders, but this maroon box seems to register as a collider when baking nav meshes
Does anyone know where this could be coming from?
Okay, I fixed that issue by using render meshes, but now the agent will stop at the end of each navmesh, instead of moving to the next one, even though they're connected
Okay, so the problem was simply that the height of difference in navmesh height was too great. problem solved lol
Hello everyone who can suggest a good A * lesson for 2D games isometric
I couldn't find anything for 2D
Can anyone suggest a complete pathway for creating AI in unity from beginner to expert for everything like Car AI , shooter ai , zombie ai etc (no money and time issues)
What are my best option for using behaviour tree inside unity?
Nah I never lag
Were you live then mars? Your messages seem to be a bit late
Hi all, I am getting this issue with NavmeshAgent.remainingdistance on all my agents. Im using the remainingdistance to stop within a certain distance, but my check always triggers immediately because I always get a first hit of 0, before it then proceeds to the correct distance. I'm getting around this currently by skipping the first reading but its a bit annoying and surely can't be usual practice.
Try changing the order in your code that might help you might be checking distance before you set the target
is it possible to make a navmesh agent move toward a point while NOT forcely facing it towards it?
You make him go to the point and into the update lookat the point you want to
There is probably a better solution :x
That's what I do too.
Hi, I have a nav mesh obstacle related problem, and I already wrote a post about it in unity forums but to no avail.
I would appreciate any effort to try and help me, post answers either here or on the original post below.
https://answers.unity.com/questions/1828366/painted-trees-are-not-acting-as-obstacles-on-navme-1.html
Can I use the NavMesh System so my Object moves in a grid instead of simply "walking"?
If you want to move objects in a grid it is better to simply use this in an Update:
Vector3 direction = target.transform.position - transform.position;
transform.Translate(direction * speed * Time.deltatime,Space.World);
***To my opinion
I have my movement done already. But I need the AI to move in a grid and not with speed and acceleration and stuff like that
Well the basic movement of the Agent is in a straight line if there's nothing in the way.
So maybe you want to think about making a grid of empty objects?
Hi guys, is anyone noticing the NavAgent seem to move a lot faster on android built?
hi! is it possible to save a navmesh to a prefab room that can be instantiated?
How performant is the real-time navmesh stuff?
Been thinking of using the real-time navmesh to make a large AI physics-based snake avoid getting stuck on itself by using the real time nav mesh to make it see it's own body as an obstacle
but was have a really large navmesh on our game and I'm not sure how performant it would be to do the cutout stuff on it to cut the snakes body out of the navmesh
from my experience navmesh obstacles are quite performant, if that's what you're referring to
Hey guys is minmax ai a common use case for dots?
It's a bottlenexk for my strategy game and I was wondering if ecs would help
Gentlemens, a question about the implementation of the behavior tree. I saw two options, a simple and understandable for me uses ordinary links to execute related nodes, the second option is built on a stack. In this case, the stack is filled / cleared every tick. What are the pros of 2, does it just work faster or is it needed for some additional functionality?
Panda if you like text, behavior designer if you like graph
I believe scene cam is diff to player cam
you won't have to worry about that in a build
Confusingly enough - you can preview frustum culling by opening the Occlusion Culling visualization window.
Hello, I'm struggling trying to have a collider work on a object that has a navmeshAgent on it, wondering if anywaone knows of any bug related
have to point out that I'm not using internal calls (on collisioEnter/exit etc.. ), I'm doing an overlapsphere and untile I don't add a navmeshagent to the object I'm able to detect the collision
collider doesn't work no matter what, tried with trigger on/off, multiple size/type, on the same GO as the navmeshAgent and on a child... but nothing, if agent is On, I don't get a collision
if it is Off all works (already checked layers/tags/physics menu) done a gizmo on the collider (spehere/box) and the position size are right
...forgot to add... a rigidbody (kinetic or not) doesnt make a difference, also disabling the navmeshAgent at runtime has odd results, sometime the collision is detected, sometime not
I don't know about all that, considering this is #🤖┃ai-navigation I would try #🔀┃art-asset-workflow but what I do is make sure for example your sword is a child of the hand bone
@alpine glacier yeah that's a good point
Solved, Colliders monobehavior transform position is not updated when physics is off,
Anyone know how to fix this navmesh issue? I have some colliders that follow the door frame, but it covers the entire mesh instead of making a hole in the middle.
I imagine you tweaked agent radius and height to rule those out?
No, but im experimenting with it now and it doesnt seem to do the trick..
could always bridge the gap with a navmesh link & enable/disable it depending on whether or not the door's open/closed
https://docs.unity3d.com/Manual/class-NavMeshLink.html
I’m never late and I live in California
im glad i only reply to people who reply in less than 27 days :D_ _
If still doesn't work, you could try playing around with the voxel of the navmesh, it may affects the results, just a guess I'm not a specialist
So i got kinda the influence calculation but i wonder how i can make it without Vector2.distance because that makes no sense with walking range e.g. so how do i iterate though it? And how can i add a threshold so the enemies wouldnt take over the influence map? Function Frequenzy is 1Hz. The Influencemap got a list with his upto 4 neighbours
public void CalculateInfluence(ref InfluenceMap influenceMap, Transform[] enemyAgentPosition, Transform[] alliedAgentPosition)
{
foreach (InfluenceNode node in influenceMap._influenceNodeGrid)
{
float inf = 0;
foreach (Transform t in enemyAgentPosition) inf -= 1 / Mathf.Sqrt((1 + Vector2.Distance(t.position, node._Position)));
foreach (Transform t in alliedAgentPosition) inf += 1 / Mathf.Sqrt((1 + Vector2.Distance(t.position, node._Position)));
node._Influence += inf;
Mathf.Clamp(node._Influence, -1, 1);
if (inf < minInf) minInf = inf;
if (inf > maxInf) maxInf = inf;
}
map = influenceMap;
}
in my enemy script, I have the communication method. which is used for communication between two enemies when there in range of each other.
my problem is that when enemy A detected player enemy B won't stop chasing the player even when the player is out of chasing range.
here's the code: https://pastebin.com/kTbgG6Ur
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I don't understand your question but since i did influence map without distance a while ago using cellular automata (i think) here it is https://forum.unity.com/threads/using-asyncgpureadback-to-compute-influence-map-with-a-compute-shader.539487/
(Based on someone else's work)
Do we discuss ML too here ?
there's #archived-machine-learning for that I think
I am official blind now. Thanks mate.
😂 np
hello guys anyone used the minimax algorithm down here please ?
hey guys, having a weird behavior with the AI Planner. In the decision controller, when sending one of the objects as a parameter for the callback function, the gameobject is null
this doesn't happen eveytime, and the objects for sure exist in the scene
has this happened to anyone else?
thanks 🙂
Anyone try NodeCanvas or Behaviour Designer? I'm hoping to upgrade my AI's FSM to a behaviour tree but I can't seem to decide between the two
Anyone here have much experience with A* Pathfinding? im looking for a way for my enemies to ignore the player if they are outside the enemies pathfinding grid
Which component is the AI one?
@proud wigeon Unity doesn't come with mature AI solutions beyond navigation. Actual decision making AI is something you need to build.
I have a pretty large Navmesh Surface that bakes, and I want to bake in runtime pretty often. Is there a way for me only to bake a section of the navmesh surface, instead of all of it? I've tried separating it into multiple navmesh surfaces, but they all cover the same area despite trying to have them cover different square'd chunks.
I had pretty much this exact same issue recently
The problem with splitting up a navmesh surface is that your agents won't be able to move between the different surfaces without off-mesh links/navmesh links, which in my case wasn't ideal
I ended up using NavMeshSurface.UpdateNavMesh(), since only updates tiles that have changed (https://github.com/Unity-Technologies/NavMeshComponents/issues/95#issuecomment-419983756). It was really slow for me at first but after a bit of digging I discovered that setting both NavMeshSurface.ignoreNavMeshAgent & NavMeshSurface.ignoreNavMeshObstacle to false improved its speed to the point where I could call it as often as I wanted with very little impact on performance. Playing around with the surface's Voxel Size & Tile Size properties also seemed to help.
If that doesn't do the trick, in 2020.1+ there's a NavMeshBuildSettings property called preserveTilesOutsideBounds which when true will only update tiles that are completely within the current bounds of your surface (https://github.com/Unity-Technologies/NavMeshComponents/issues/95#issuecomment-609466521)
Thank you so much! For me, I realized that changing voxel size did most of the trick. This will be a huge help for future reference though. ❤️ ❤️
No problem, glad you've got it working! 😁
is there a way to bake objects while the game is running through a script
Bake navmesh? Yea should be doable since NavmeshComponents do it
this is currently the code im using for AI wandering
Its a bit to random, and results in frequent bumping into walls and the enemy is... not convincing
The first thing to consider would probably be predefined paths. If creating predefined paths isn't feasible (large/open world), some sort of steering based on navigation edges should make the behaviour a bit more believable
I need your help - so i got kinda a influence map (2D Grid) but it dont use the Obstacles? So how do i need to iterate though my nodes to archive it. Because rn i only using Vector2.Distance for the Influence calculation but thats wrong.
Somebody any tutorials or something
;
Hello. I have the following problem: I have a bunch of NavMeshAgents that are following the player. The problem is that since they all follow the same path, the player can just run circles around the level with the enemies following it. Not very interesting.
I want the enemies to take different paths to the player, possibly flanking him.
My idea here would be for all enemies to have an area around them that increases the navigation cost, meaning there is an incentive for all not to follow the same path
From what I'm seeing, the only way to do this is to constantly being rebuilding the NavMesh right?
Does anyone know how to fix this
when i activate my animation it just makes it stuck in the ground
pls help
Looks like a default humanoid pose. I would double check that the animation data matches with the bone setup
ok
@sinful matrix Don't crosspost questions to multiple channels.
ok
Looking into planning algorithms, what is out there beside goap and htn and commonly used?
Hello, I'm currently creating a complexe behaved enemy drone, but my only one script begins to being pretty fat, so I'm thinking about using behaviour tree, I heard that they're pretty efficient, but I lack of knowledge about how to code it
I have more than 25 functions on it, I have to create a script for almost each of them ?
BD comes with a lot of nodes so probably less than 25 you'll have to program
Panda BT is even easier to use
anyone know of any really good tutorials on how to have enemy navigation/patrolling?
Oh thanks for the response
And also, where can I report an issue
When I try to gizmo a point obtained by NavMesh.SamplePosition my editor shut down
I'm currently working on it on my project, but I didn't find anything consistent
Im using some code for basic navigation where they just walk around at random positions but its super super broken
i tried making it so they went to multiple set points of invisible cubes but they broke after like 5 seconds
My script select a random point in range, use sample position on it, check if the path is available and check is there are obstacles around it at a given range
more advanced than mine
mine just goes "you want me to move at a random position in a 20 meter radius alright"
It's still not very natural
then gets stuck in like a ton of spots
Do you use setdestination ?
let me see
With a correctly baked navmesh there is no way to being blocked in a simple situation
lol its probably not correctly baked
public static Vector3 RandomNavSphere(Vector3 origin, float dist, int layermask)
{
Vector3 randDirection = Random.insideUnitSphere * dist;
randDirection += origin;
NavMeshHit navHit;
NavMesh.SamplePosition(randDirection, out navHit, dist, layermask);
return navHit.position;
i think this is what generates the random location
This is more or less my searchDestination func
Oh this is some complex terrain
I don't know level designing yet
You should precisely set your layers
And sometimes the navMesh clips just a little bit inside meshes
all those holes are because of trees or bushes
Try to raise it just for checking if everything is good
im not sure how to disable the holes from the bushes
Idk either, I only practice on super cuby terrain
tbh for this project i kinda want to just work on it even though its a class project
Oh I see
just wanna make things work like i want to
the ai being goofy is probably the worst issue
For my wander/patroll, I want my agent to smoothly move around a point, any idea to how create a function to do it ?
AI is the first thing I worked on on my project
I want to do it for my patroll points, and then change it then and then
Like a hybrid behaviour
It would be a good start
But the orbit-around a point will be also useful for combat
You use a point list patrolling ?
You can asynchronously update a navmesh surface with UpdateNavMesh
https://github.com/Unity-Technologies/NavMeshComponents/blob/d6b8bcd42c62089b3209c556d4ff7bccc13d1588/Assets/NavMeshComponents/Scripts/NavMeshSurface.cs#L184
So I'm using calculate path for my navmesh agent to move along (normal method moves too weirdly) but the navmesh points hug the very edge of any object they go around causing my agent to get stuck. Whether it's ignoring the agent radius or what. Any Idea for a fix?
Agent radius doesn't change how pathing is calculated. A bit confusing. What you need to do is either using navmesh component from GitHub or increase your baking radius in the built in navmesh
Can someone help me with navmesh?
FULL 3D ENEMY AI in 6 MINUTES! || Unity Tutorial:
Today I made a quick tutorial about Enemy Ai in Unity, if you have any questions just write a comment, I'll try to answer as many as I can :D
Also, don't forget to subscribe and like if you enjoyed the video! :D
See you next time.
Links:
➤NavMesh Components: https://github.com/Unity-Technologie...
i copied this video but all the enemy does it follow when in range. otherwise its static
if there are any Unity wizards that can help that would be appreciated
How do you guys feel about AI "cheating"? in the sense that they get extra info that the player wouldn't have access to? obviously in a goal to make the ai more competitive to the player.
could be wall hacks for fps's, stat details for rpgs (along with exact damage calculation after rng), better stats for sports games, etc
I don't see why the AI wouldn't be aware of the players position at all times
or an RPG Enemy not aware of the stats of the character
All that matters is user experience matching game type
Sometimes it just bad, like instead of making the AI more challenging, it just ends up making the player frustrated, the rubberbanding in NFS series is a good(in a bad way) example of this.
Mario Kart too. And most fighting games read inputs. It sucks because you feel like you're either punished for getting better, or at the very least not rewarded for it. But it depends on whether it's obvious or feels like they're cheating, and how much too. I assume most AI is cheating somewhat.
like jelly drift AI they dont even drift
Hello, I'm currently trying to build a behaviour tree, and I want my agent to randomly search a point on the navMesh he's currently on, this function works perfectly but it needs very often than one frame to find the point, as it tries random points then check if it is valid, and then returns success.
But I'm blocking at the part where I want the agent to find a valid point after a certain delay, I wrote a timer node and put it and the point search in a sequence, but it will allow the point search to occur only once, so it will probably fail to find a valid point, so my question is, there is way to reset a timer node only with the success of another node ?
(I feel like a need to ask help here to have my brain working full speed at the troubleshooting, since seven minutes I figured that I just have to incorporate the timer system inside the node I wanted to be timed, this is still a little dirty as a tweak so if someone have a cleaner and more versatile approach, please give a hint, it'll probably help other people as well)
so i am new to unity, but listening to your first problem: "but it needs very often than one frame to find the point" made me think of the solution i often use in programming, if something takes longer than you expect/need it to, run the code earlier and save the value and call to the value when needed 😄
I once programmed a matchmaker for a specific game, and it took very long to accurately find a good match, so my solution was to run the matchmaker code while the previous battle was occuring, giving the matchmaker the time it needed to appear instant
can anyone help me?
i want to make the path under the box walkable
im using A* pathfinding Arongranberg
If you want both levels to be walkable, you need to use layered grid graph. If you only care about the bottom level, you need to lower the height testing parameter, or alternatively, put the box into another Unity layer
Oh how do I use layered grid graph?
Found it
Wait wtf it doesn't exist on the free version
Dang
Is there a way to use Rigidbody physics to move an enemy with NavMeshAgent
Hey guys i'm struggling with this piece of AI code about steering behaviors for wall avoidance. Notice that my agent keep hugging the wall despite adding a force which is supposed to repel him from the wall using the hit point normal. I have attached a gif and some code. Does anybody see what I am doing wrong?
The bulk of the work is done in WallRepulsionSteeringBehaviour.cs
https://gist.github.com/OliPerraul/0b6e870f988f474a80d56a5dde3f98d4
Thanks
There's a couple of possible causes. You have to give us more details about what are you trying to do. Is the geometry skinned? Is it linked to the physics engine or navmesh system by any component?
ah i fixed it by now
Alright, that's good 😄
Hello, i am trying to do an A.I but i am having problems, i get these messages, and it cant run the A.I correctly, these are the messages: 1.- Couldn't connect to trainer on port 5004 using API version 1.4.0. Will perform inference instead.
2.-Unexpected exception when trying to initialize communication: System.IO.IOException: Error loading native library
The code:https://sourceb.in/9aeNodyj9X
You probably want #archived-machine-learning . Have you made sure all the dependencies for the ML-Agents package are installed?
Oh sorry, i have the gym mlagents and mlagentsenvs, python, pip, the mlagent package and pyth, sorry i dont remember the exact name of pyth. Do i need to install something more? Also i'm using unity 2020.2.7f
Which errors are you getting in the Unity client?
Im getting this error with AI Planner
i get that error for all actions with that trait
and this error once
[22:24:34:473] ArgumentException: A component with type:BuffFireFixupReference [B] has not been added to the entity.
Unity.Entities.EntityComponentStore.AssertEntityHasComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType componentType) (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/EntityComponentStoreDebug.cs:280)
Unity.Entities.EntityComponentStore.AssertEntityHasComponent (Unity.Entities.Entity entity, System.Int32 componentType) (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/EntityComponentStoreDebug.cs:286)
Unity.Entities.EntityDataAccess.GetBuffer[T] (Unity.Entities.Entity entity, Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle safety, Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle arrayInvalidationSafety) (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/EntityDataAccess.cs:1070)
Unity.Entities.EntityManager.GetBuffer[T] (Unity.Entities.Entity entity) (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/EntityManagerAccessComponentData.cs:313)
Unity.Entities.ExclusiveEntityTransaction.GetBuffer[T] (Unity.Entities.Entity entity) (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/ExclusiveEntityTransaction.cs:127)
Generated.AI.Planner.Plans.Balance.ActionScheduler+PlaybackECB.Execute () (at Packages/generated.ai.planner.plans/Generated.AI.Planner.Plans/Balance/ActionScheduler.cs:62)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <6a104889781c465ca00c12d0953583e2>:0)
Can AI Planner be used without DOTS or how can i fix this?
ai, maybe you can help me!
im making a 2d rts game and I want some of my tiles to be resource tiles, ala red alert, where you can path over them but a collector unit can gather it.
Whats an efficent way for the collector to tell which tiles are resources vs just any other tile?
depends on a few factors, personally I prefer a dictionary where key is the tile coordinate and value is relative to a resource. If it's a small map you could use an array or assuming you have a visual element to indicate resources at the tile. That game object could be used, just do a ray cast or sphere check that your in range with your collector against the object.
Many ways to handle this that's just a few ideas.
Or would it be better to go overkill and learn ML Agents, or maybe just code my own AI? A multilayer perceptron should be enough and ive already coded a multilayer perceptron visualization tool in unity once, so making one wouldnt be too hard, the reason to use ML Agents would be because ML Agents unlike AI Planner seems to be Unitys Posterchild, so theres alot more documentation and resources and support for it than for AI Planner, which everytime ive tried to use it has just been a broken mess that doesn't really work
using A* for the first time and i have no idea how to change the target to make the seeker follow a gameobject with a target instead of just a transform i insert. i looked it up but i cant find anything so can anyone help me?
oh nvm it's being explained in this brackeys vid lol
I need somebody to check my code to spot mistakes and tell me some major improvements https://gdl.space/wifuvopiwa.cpp
sorry I found some mistakes myself I will send the update when I fix it
Is there a way to use NavMeshAgent with the Job system?
I need somebody to check my code to spot mistakes and tell me about some major improvements https://gdl.space/lulorecila.cpp https://gdl.space/folaguqiho.cpp
Your code is indecipherable. What on earth are
child1.WXA = ParentA.WXA;
child1.WXB = ParentA.WXB;
child1.BXX = ParentB.BXX;```
If you want people to code check for you, you need to follow some sort of coding standards. Which means descriptive names for variables, comment your code, use standard C# naming conventions.
I don't know the conventions
Maybe that's something you could.... search for? Instead of tagging me to tell me you don't know something that is very easy to find online!
The WXA are the w values in the first part of the conections and WXB are the w values in the second part. The BXX are the biases.
Can anyone reply to this?
@orchid crypt Please don't spam the channel.
Hey. I am new to creating ais so I'm hoping I can get some help. I'm trying to create zombies and I use navmeshagent.Destination. But this makes all zombies go in the same direction till they turn to a clusters of zombies. How can I make them space out. While still making the player their target. Only clustering when wanting to attack
@winged relic i went with an overlap circle and it seems to have accomplished everything I need. Didn't realize the solution would be so straight forward
That's the main selling point for pro 😔
Please an answer 🤧
You don't want the player to be their target until player is withing a certain distance.
You need to plan and add some behaviors, things like patrol area, guard, or wander aimless over all the world. Attack is another behavior when criteria are met
Decide what they should be doing and then look into how to implement 😉
I imagine David meant entities bunching together while in the attack state
maybe some kind of flocking behavior could do the trick, choose a 'zombie leader' which leads the flock to the player
are there any AI behavior assets worth buying or should I program my own?
Well it depends, do you want to code it?
anyone seen/or is watching Bracys tutorial for a RPG game
When using A* Pathing Project, how do I add a new Layer to the obstacle mask?
It might be using the Unity layers?
it does but how do i specify which layers are obstacles and which are not?
somebody with experience in navmesh 2d? (NavMeshPlus)
because works fine but if i need setdestinatation only changing the axis y, the agent stucks and move so slowly
Hi. I am trying to implement NPC AI where they take decisions based on "emotions". Like each NPC will have fear, confidence scores etc.
Is a stronger enemy nearby? Increase fear.
Is an ally nearby? Increase confidence.
So then the NPC shouldn't attack the strong enemy because it's scared of that, but when it gets together with an ally its confidence will increase and it will team up to attack.
I want to research more on this. Is there a technical word for this kind of game AI? Googling for "emotion based game AI" isn't returning expected results.
You can achieve that with UtilityAI, if you want to go to that point of "complexity"
is the #archived-machine-learning room dead?
Nope
or just not many people there
having some very weird ML problems that cant find docs about xD
Give them time to respond
alright
How complicated is it compared to say behaviour trees?
It's a step above. It's another way of thinking.
But it's not so complicated. THe nightmare can be when you try to balance things, because it can lead to emergent behaviour, which can be tricky to anticipate, because well it is emergent :p
Well my goal is emergent behavior as I am trying to make a sandbox experience (like Mount and Blade). So that's a plus for me :P
Thanks for the help. I had heard of utility ai but I didn't know it was based on scores like I wanted
Yes it scores Considerations (what you called "emotions", but can be broaden to smthg else) to pick Actions, based on the Context you provide to your agent. Very powerful, but at it's core it's just scoring equations :p
I recommend the work of Dave Mark and Kevin Dill. They made a bunch of interesting GDC talks you can find online
Thanks. I am looking at their GDC talks now
is neural AI even worth using in practical games or not yet?
like lets say a quake 3 style game
I'd say it depends a lot on your project
Usually you need massive amount of data for your neural nets, so if your game is not out yet, how do you gather data ? That's smthg to consider
Might work for early access otherwise you can get stuck in an infinite loop where your can't release the game until you finish AI but you can't finish AI until your game is released and has lot of players 😛
You can still have an AI that learns from the players, I think that's interesting to have
Well the thing is you can have your AI play against other AI and it would somewhat work?
Oh? you can still teach the AI on a release project?
Thought it would need python cmd to be running and such
Yeah, Blizzard did it for its Alpha-thing, but they spent insame amount of money with server costs, can you ?
👀
I've seen web & mobile games have their agent continuously learn after the first training
Was with tensorflow if I remember well
anyway guys in #archived-machine-learning will be more knowledgeable than me 🙂
yeah still waiting for htem to wake up xD
still need to ask why my damn observable goals get removed when i start teaching my AI 🤔
still quite a lot of funky stuff going on when trying to build ML agents, but at least its not as painful as several years ago
Yeah last time I checked they already had plenty sample project on the official unity github. Can't find your answer there ?
their examples have static amount of goals and normally just one target, too
and i already skimped through their github tutorials, plus watched one on youtube that seemed competent enough twice
nothing i saw there about my problem
:/ I'm sure people will see your message in the next 24/48 h 🙂
Think i mightve figured it out 🤔 one of the problems at least: removing [SerializeField] on the list of targets for the AI somehow fixed it?
Does anyone know how i can make the impoirted animated monster i just got work? i added my enemy script to it and it roams and follows but the animation doesnt
does it have an animator componet attached? is the avatar and animator set correctly? Is the animator set up with animation states and parameters?
im new but its got a controller
idk what i have to do to make it work
@stark sage
having a issue with navmesh offmeshlinks overlapping that when the character jumps from one destination to another rapidly
when I am moving from another position while there leaping there
nver mind I fixed it
Hello! I am making a game in which I need some enemy car AI (its a racing game). So I would be grateful if anyone could dm me or ping me with some code for a simple car ai
Hello, having a issue in navmesh has path to go for destination but my agent is going a side where obstacle are there is not path to reach target but still it's going there.
What happen to a AI trying to go a point outside of nav mesh? AI buged ? Rip ?
Not really unity specific but does anyone here have any experience with Utility based AI approaches?
as im struggling to wrap my head around use cases for lets say "should attack" as almost all documentation so far is based on the notion of you knowing health, distance to target etc.
However what if you have 10 targets, how do you express the singular "should attack" when really it may be different depending on all the targets, also how do you decide which target to ACTUALLY attack if you do decide to attack etc.
as in my specific scenario its like a turn based strat game, so the unit can move X squares, use Y ability on Z target. However really to be able to know what end action to go with I need to know each of these 3 things, but to know where to move and what ability to use I need to know the target, and same with any of them and im really struggling to find out how to handle these chicken and egg problems
You used the "decide" keyword a lot, as in you're looking for a decision making algo. And that's exactly what UAI is. So you would have a target selector, which would evaluate each targets you memorised in the agent context and score them towards "the best target" to pick, eventually resulting in one winner or none. Store the best desired target back in the agent context memory. When you have one, your decision graph now has all input necessary to decide which action to execute
Does that help ?
sorry had a meeting let me read
yeah so thats what I expeced you score each enemy individually but it seemed like a more dynamic thing, and everything written about was fairly up front and set in stone.
I am unsure on the correct terms but you have an action of some kind "attack", "heal", "hide" etc and then the values which are used to derive the utility, but I wasn't sure how to express "should target unit N" as really I guess the thing you are querying is the target viability so you could make a class or something up front which acts as that but it doesn't seem to fit as an "action" of sorts so from an architectural perspective not sure where it fits into it all.
so as you say I can score each enemies distance, and/or their health so I know the lowest HP enemy and closest enemy etc, but this feels like aspects that effect the core decision making process, but if as you say you just run through all of these checks and store results somewhere as like a blackboard or some context that others can hook into I guess it makes more sense
You can also have some kind of composite/recursive scorers if that helps handle this special cases but that can also complicate things
or you can have actions with Options, thatdo handle their own best option selection logic
are you using an existing solution or implementing your own ?
implementing my own, its not unity specific its just generic c# atm
this is one thing I liked about the utility approach it seemed fairly simple to model:
stimuli/values + weighting_function = utility
yep, scorers can be as simple as equations
so I could just model each possible action/need and provide the required values/weightings etc
its just I couldnt align this mentality with how I would actually use it in the strat world, as it seemed I needed to get loads of contextual information first before I could decide on actions. Like all main examples use how far away a target is to indicate what you should do, but in the real world you have N targets all varying distances away
and in my use case you can only move X amount and have N abilities all with their own ranges etc
so I needed a way to factor in all the possible bits of information to come up with the best scoring for outcomes, i.e no point checking if I should attack if no one is in range, or 3 enemies are all possible targets but are resistant/low health/can counter etc
tbh its not going to be as complex as I say there, but it was just when I do these checks, as it feels a bit like chess AI where you do every possible move for N turns to see what gave best score, then go with that move
UAI is reactive, I would only go evaluating with the info the agent knows right now in its current context. The system is reactive enough to update behaviour as the situation evolves
in my opinion anyway 🙂
yes I agree its only supposed to action on the here and now, but I knowing what target is a good target requires a few different checks, i.e how far, how much hp, can they attack me etc
and I guess that always needs to be scanned constantly and updated as you need to know this to correctly weight the other bits
also do you know of any good open source implementations of something like this (not fussed if its engine agnostic or unity specific)
I found crystal AI but it seemed dead
did you implement different refresh rates for multiple parts of the brain ? You can have some reflex system that exec every seconds, but the enemy scanning once every 10 seconds for examples, allows some performance savings and can be justified by some tunnel-vision-action-committing :p
I loved the one from apex game tools, but they seem out of business. They released their framework open-source I think its LGPL now
I havent implemented any of this yet, I just am at the point where I need to implement something so was looking at approaches. I would probably just scan every time a turn is started though
oh are they? they did quite a few things like pathfinding/ai etc from what I remember
Oh right you are turn-based, I always assume 3d real-time, sorry
sorry yeah its a really simple 2d turn based thing, but its mainly an example project but needs some basic AI
Yep, those guys. Started well it's a shame they didnt make it in the end
same sort of thing with the uFrame guy, made some great libs but not enough sales
Back to your question, other than the apex guys implementation, for UAI i love the work from Dave Mark and Kevin Dill, not really an open-source repo but you can find lot of their GDC talks online. Then also I learned a lot from the Game AI Pro books, which are a collection of papers you can find at some places online (they are expensive but web version is free)
ah thanks
it seemed like there would be a few popular open source libs for this as the basic paradigm seems simple and it doesnt really need much of an editor, you could get some benefit from using unity animation curves for activation function style functions or something, but other than that its pretty much all just code stuff, I also like how you can pretty much treat it as readonly and have it in another thread just whirring away whenever needed
Exactly
but as this is kinda just an example project for some open source libs im not trying to go too crazy in depth on it all 😄
100% agree. Then I love GOAP for higher level planning, but didnt have time yet to try to mix both, would be my dream-AI 🙂
yeah I looked into GOAP as well, as I have done FSMs and BTs plenty of times and they were fine but needed a LOT of guidance, GOAP was nice as you could just give it a set of actions and it could kinda pathfind its way to a result
but still felt like it needed more steering and control that utility which seems to be able to scale REALLY well
but the double edged sword of emergent behaviour is a benefit and a worry 😄
Yeah maybe just scorers equations would be enough for 2d turn-based, eventually some additionnal classes to bundle a light decision-making framework. So other people or modders don't do dumb things. But Don't 100% listen to me. I'm the kind of feature-creep guy who shoots flies with bazookas
well once I get the basic "example" version done I plan to put it into unity and actually make a real game of some sort with it
as atm its actually run through Blazor (As the series was on view separation and how your game can run anywhere)
Yeah like UAI for individual level, GOAP for team level
I mean that's how I see it
it could be dumb
well atm it just picks a random target and attacks, so anything is better than that 😄
My NavMeshAgent AI is stuttering on the X-Axis when following the player (setting the destination in Update)
My Rigidbody is Kinematic as well. It's also not because of my camera, I do these calculations in LateUpdate. Any ideas?
Anyone know of any good ways to get NavMeshAgents to detect a ledge to either climb up or down it to get to a new navmesh area? I've been stuck with this problem for a while.
Try that https://github.com/Unity-Technologies/NavMeshComponents/blob/master/Documentation/NavMeshLink.md
Just a suggestion of something to look into, Influence Maps. I'm writing a TBS in my spare time and was struggling with how to get my AI to do certain things, however I wrote my own A* pathfinding which allows me to use the influence maps for avoidance, spotting weak areas in defense etc. They tie in nicely with score based decision making too imo.
I must look into this "Utility AI" stuff as I'm just rolling my own at the moment, lots of trial and error. best of luck 😉
They mention these in the arena net gdc talk on heart of thorns
My disconnect is more around how you handle these different aspects of the data, like every talk so far has mentioned targets/enemies, but the action or example phases always only factor in a single enemy
So as we discussed before at some point you need to go through all enemies and get some contextual info like check how far they are from you, check how much agro they have, check if you can actually hit them etc. However that information can only really be factored in if it is a 0-1 value
I am not sure if it's basically scoring this data, saving it. Then multiplying all enemy scores together to be used within the "should attack" action
As you don't know if you should attack without knowing all the stuff I mention above, but you may not even need to check if you are going to heal or something.
influence maps can contain lots of data, I have a few some tell me of my "attack" strength at a given area so it helps with unit coordination, often stored as color values but it could equally be data in an array. They are very versatile and useful it's just getting into how to use them at the start, then let your imagination run wild with the possibilities.
I'll give a rough outline of how I do mine, basically each unit has a "memory" of units nearby so it knows when seen and basic info like range, attack, vision distance. When the intermittent scan runs it checks against this for changes, after x turns if not seen and not a building it gets removed. This saves altering the influence maps all the time, be this good or bad practice 🤷♂️ it makes sense to me 😛
This information is passed onto a "commander" who collates this info into influence maps. This means your AI knows that at a given spot on the map the enemy can attack with X value. It's not single target data, it's handling all threats at once. Which is then used in support of deciding which unit to attack, you still have to grab a list of enemy units within range and iterate over them to decide which is a viable target. But you have information to hand of the bigger picture not just the single enemy you are analyzing.
I'm just a noob though, poking at it when I have time and motivation. My a.i. is still evolving as I'm learning, hopefully for the better but without influence maps I struggle to think how to handle all this information in a quick efficient meaning full way. It ties in nicely with a score based approach to decision making. They have been used in games since the 90's especially TBS and RTS type games, but finding good information on them is still difficult 😉
Yeah I mean ultimately it's going to be querying the same sort of thing it's just as you say where it gets stored. Utility AI talks don't really address this as they just talk about inputs but ultimately this information needs to be available in calculations so I can probably just store it on each objects blackboard or something nearby units and their scores. I just seems a real crucial part of the Utility AI puzzle but is never explicitly talked about
You put whatever you want in your agent Context
UAI is a decision-making pattern
the sensor parts are often on Unity side
That is if you see your AI as a SENSE/THINK/ACT sytem
In your case you want to go a into a little more depth for your targets classification, one way to do it is handling it as a decision to be done by the AI, but sure you can detect threat level through influence map 🙂
The context though normally would be singular vars right?
And also the data about the enemies needs to be processed somewhere, so I can derive some meaningful metrics from the enemies, so if we agree we just throw an entry for every enemy into the context/blackboard for each agent, then in not sure entirely which bit is in charge of keeping it up to date, as that's another unclear bit.
I get that at arbitrary intervals or triggers you reassess the values of things to keep the weights up to date. Then the Actions use those weights to derive best outcome. However it's not clear which part architecturally speaking manages this, or if its just up to you as the dev to have some ad hoc process which keeps it up to date.
As so far the terms and jobs seem to be:
Value - a numerical non clamped representation of something, I. E ammo, health, distance
Modifier/Function/Reasoners - the graph function which is applied to values to get a normalised output
Considerations/axis - The actual weighted values that are output for each input in an action via the functions
Actions - The high level thing that the agent could do which exposes the weight based on its inputs
However it's never mentioned (or I missed it) where the input values are maintained from at arbitrary periods
You can store any data Type in your contexts/blackboards. Maybe you think only about scalars because you want to keep it to simple equations I guess 🤔 But as a matter of fact, your qualifiers can compute a final score based on complex data types and/or even variables from multiple sources before you normalise these values for your Function.
For the updating phase of the contexts, your AI system can either be totally unaware of it (in Unity the sensor part is often done with Unity specific ways like Raycasts, trigger zones, and such; but don't HAVE TO: can be as simple as distance checks) or as we saw in your example, you can apply some AI decisions during the scanning process (this will result obviously in different knowledge for each agent). From the AI point of view, in the former case the Context is read-only, in the latter it can write some parts of it.
any good path finding algorithms?
you mean A* or do you mean A*?
i already decided to use raycasting lol
huh? raycasting isn't a pathfinding system
plus, all the major A* pathfinding projects use raycasting to build a graph
here's a random example
https://gist.github.com/dunenkoff/31c854d6b02eaa68e7ab
@real sonnet all makes sense, given I'm already using rx it seems like some of this can be represented as computed collections which could just be rebuilt externally
Thanks again for your advice
Hello everyone , I am stuck to find 2 different path for same destination is it possible ? if possible then suggest me something to solve this issue.
i am using UnityNavMesh system
I wanna make a simple NPC that is friendly to the player and just walks around the scene, but I have no clue how to start. Can anyone help me please?
Hey! I'm a new to coding I have a question about how to get a wandering AI to get information of things it notices
I do a checkSphere to find things of interest which it does let me know it has notices something but I have no idea how to actually get information from what it noticed is there a command I can't find? or is using checkSphere the incorrect method?
What do you want it to notice?
Try looking for "wandering AI" or "patrolling AI" on Google or Youtube
CheckSphere will only return a boolean so yeah you're stuck. Try OverlapSphere for example, it will return you an array of Colliders, from which you can get the gameobject or scripts attached and so on
guys, I am using a NavMeshAgent on two characters, and I have a NavMeshObstacle. The problem is, that I want the NavMeshObstacle to be avoided only by one of the characters, and I want the other character to ignore the respective NavMeshObstacle. How would I do that?
@golden kettle I'm sorry for resurrecting your post 2 days later, I don't check here frequently so only now I could see it
I would like to share my knowledge as I finished my first Utility Theory AI with visual editor this week and I also stumbled on this exact same question
Many nice things have been said already by other users, regarding having an extra layer of sensoring, and that sensoring might be decoupled to the UT decisions making itself...rather, you just sensor the field from time to time and have the UAI to use that info
This is very good and is how I like to express/think about AI, and the sample game that I have made with my AI editor uses exactly this approach...at every X seconds, it analyses the enemies and finds the one which has higher threat level. Stores its relevant info into the Agent's blackboard and the UT just uses this data when needing to attack
Now, even though I used this approach, I still pretend to explore what you asked about, which I call as "contextual decision making", meaning decisions that has to be done one or more times, depending on the amount of something. This "something" can be an enemy, it can be a place, it can be collectibles on the field, etc. I want to try it because Dave Mark himself exemplified a "per Target" scenario which would be "the same action, scored many times, varying the target"...IN the UT, not somewhere else (as far as I understood)! Here is a screenshot of the moment where he mentions it
This is the video: https://www.gdcvault.com/play/1018040/Architecture-Tricks-Managing-Behaviors-in
That part is at ~38min
look into baritone maybe for A*?
it would be easy to port as it's java and C# is java based no? Or am I just being stupid
Now, if I really decide to try to add it to my solution, it would probably be something like this:
- My UT editor is inspired by another Dave Mark's presentation where he mentions that these "actions" or "considerations" can be dynamic...i.e you could add/remove them, during runtime, depending on the current game state. IIRC, he exemplifies it with a character which goes inside a "bar" and doesn't need anymore to think about fighting, but rather just socializing
- As I created it based on this possibility of dynamic adding/removal, my system has what I call a
Consideration. It is pre-defined during edit time, the possible considerations, and added to a dynamic list. These are then scored, etc - I can, then, create multiple Considerations at runtime, each one having a specific Target as part of the parameter, where the Targets would be "discovered" in runtime. Create N instances of that Consideration, varying the target, add it to the Considerations list, score them, and so on
Now, I'm unfortunately not sure if this will work, if it will be possible too expensive/obscure, but this will be my starting point, some day. So my answer to your question would be that your "considerations" doesn't need to be fixed and unchangeable. Take care with allocations ofc. But I might be following the wrong lead, I can't say right now for sure
Just to finish, you asked for some open source UAI, and I have this one starred: https://github.com/apoch/curvature
It's Curvature, IIRC it was done by Mike Lewis, the guy who does the talk with Dave Mark about the UAI in Guild Wars
He even answered some interesting questions on the "issues" tab on that repo
Also, both Mike an Dave seems to be, perhaps, reachable
In case you're interested, here is Mark Dave's on Youtube, talking a little bit about Influence Maps: https://www.youtube.com/watch?v=6RGquWxNock
Wish you best of luck with your implementation
Is coding ai hard?
Depends on what type of ai you use
Implementation and using an approach require different mindsets, like you could implement fsms but make a hash of designing with them
@sonic rain thanks for all the info, I've already seen all the gdc bits and skim read the book on maths in games by Mark. I have started to implement it but I've kinda given it a sort of ecs style twist where the considerations are like components and and the actions are like groups, so I just have the considerations use observables to indicate their refresh trigger and then the Actions don't actually do anything and just look at a set of considerations and expose the highest one (or all of them if you want) then that relays onto an external handler so it's all separated
It may be garbage, but will see how it pans out, as its not using an editor its hard to really plot the curves well but will see how it pans out as it seems like rx could be really useful in notifying of changes and handling triggers and dependencies between conditions
That seems like a very interesting approach 🙂
Let me know if it goes public someday
😛
Has anyone attempted to create a Local Avoidance algorithm? Trying to create an algorithm that avoids other agents and knows how to go around an obstacle using feelers in all directions, but figuring how to weight the options so that it chooses the best direction around the obstacle
I think Arons A* has that, but its only in pro version
How to make an ai that can score
Thats a bit too big of a question, break it down some more @errant quail
I have a pong game and I need to make some AI to try to beat the player, can anyone advise on types of AI that may be useful here
Something like that, or you will get no answers, but for AI in games you have:
- FSM (state machines, each state runs through actions and transitions to another)
- BTs (trees of behavioural nodes that each do something and pass on/end)
- GOAP (like pathfinding for goals, quite difficult to comprehend)
- Utility AI (lots of isolated weights on how good something is to do)
- Bespoke (whatever you want, probably will have weightings of some kind and fuzzy logic)
Well i want my ai to score goals
Like put the ball into the goalpost
@golden kettle
So what should i learn?
again its not as simple as just telling you "go use X" all that your game AI/Logic will do is call a method on your entity/in game stuff, so do you have functions in place to kick a ball or whatever?
Also defend me from scoring
so I assume you want it to know if a ball is likely to score and if so move towards it(?)
so you would probably want to check how far the ball is away and what direction it is, then have your defender move towards it
or at least get in the line between the ball and the goal
each type of AI can do what you want its just how you want to control the AI.
FSM is probably the easiest of them to start out with and well documented
Unity already has tools that let you do this stuff visually like Playmaker/Nodecanvas etc
but if you want to write your own just make a simple console app somewhere (not even in unity) look at an FSM tutorial and build the states, transitions etc and then make an entity go from Idle to Eating or something when they get hungry:
public int State = States.IDLE;
Oh oky that means i have to search fsm in youtube to do my work
then its literally just 3 ints for the states in a static class or enum or something, then have a value for hunger or something
yes, there is no way to do this without learning something
Oh oky thanks a lot mate
if you do not want to learn how to IMPLEMENT an fsm/BT/GOAP system then look on unity asset store for pre-made tool that has it, then just use that
like you can get a free version of NodeCanvas I think
cant remember
but that has an FSM/BT thing
probably other tools that are free that do the implementing for you, then you just need to use the tool to check for the variables (hunger/distance from target/health) etc and then drive an action (run away, kick ball)
no no
its hard to say which is best
they all have pros and cons
FSMs are easiest to kinda conceptualize and implement/use
BTs are easier to use imo but harder to implement
What do u use?
varies
historically BTs, right now im attempting Utility AI, tried FSMs before with some success
only one I have not tried is GOAP
Can give me a tutorial link for dis
there isnt a single link
you are gonna have to google them buddy
just google "writing an FSM in C#"
it cant go wrong
NavMesh is unity's built in pathfinding system
so you can generate a path from A -> B with it then follow it or use some pre made controllers to follow it etc
Oh ok
If you are not a dev, or are only planning to learn enough dev to get by to do stuff in unity I would advocate just getting tools off asset store/open source that do what you want and learning them
as devving your own stuff can take ages and thats just to get something that works, you then likely need editor bits to make it useful to work with and its a lot of effort
You're probably better off to start in UE directly instead, just use their Blueprint system for starters.
Blueprints is still programming, just visually. It's mainly for learning their API without all boilerplate like UHT (Unreal header tool) and pointers getting in the way. If you are not a programmer by trade or school, C++ can be quite a mouthful, coupled with UHT it's quite complex.
Nearly everything you learn in Unity will be irrelevant in UE. Some concept translate over, but not a lot.
Sure, if you think you're capable of doing what studios with over 100 people take years to do.
Yes, see Hearthstone, Escape from Tarkov, Rust, Genshin Impact. I'd recommend you do some more reasearch before starting. This question has probably been asked a couple of million times, besides you're in AI channel right now. So maybe go to something more general like #💻┃unity-talk or #497872469911404564 for more help.
Yeah making games is hard, its more than just coding
its art, animation, environmental design, game mechanics, tooling, optimisations etc
even indie devs require multiple disciplines, but to be fair unity (and other engines) help you a lot. As you could go and spend a few £££ on the asset store, buy some decent models, pre made animations, some level geom, even some procedural terrain generators etc and come up with a basic world pretty rapidly that looks pretty good
So you can make games that LOOK AAA in unity, but its down to you as an individual if you have the skill to pull all the bits together and make it fun. Not all games need to be AAA, look at flappy birds, was a commercial success and was pretty much a tutorial app
🆗 🆗 🆗
Hi. I am stumped on a very simple problem. I want an agent to compare its own strength against a potential target.
Let's say the agent's strength is 0.5. What kind of function do I write so that the agent likes to choose weaker targets ie strength below 0.5, and dislikes stronger enemies ie strength above 0.5?
Using utility based system
Sigmoid function?
I thinking of this -
Threat = 1 / 1 + e^-(agentStrength - targetStrength)
Basically something like this.
Any suggestions?
I know Aron's Path finding does it in the pro version, but not looking to spend $100 on that. I'm also not trying to do to complex of RVOs
Really just want an AI that weighs different directions, but can't figure out a good way of weighing each direction because it usually ends up getting stuck somewhere
The way it's suppose to work is that it avoids certain vectors, aka the collidable areas, as well as avoiding the wrong direction, like going opposite to the target. The way I've been doing it is through dot products, but the issue is if there's a direction that the AI needs to take that goes away from the target to be able, it doesn't work because the dot product is out weighted by a bad direction that has a better weight value because it has a higher dot product.
Do steering behaviours do what you want? Could you use them with normal pathfinding?