#๐คโai-navigation
1 messages ยท Page 13 of 1
yes
Okay. Is it possible to split a navmesh in chunks for perfomance? My world would be relatively big (maybe procedurally generated aswell) so i wonder if having 1 big navmesh for that would be problematic
should probably use the navmesh components preview package then. You can generate a navmesh around the character at runtime.
Allright thanks
I have an agent that should walk on my nav mesh. It starts to walk but walks out of bounds of the nav mesh. How can I handle this situation?
Anyone?
How are you setting the agent's destination?
By using a circle around my Ai and randomly choosing a path in that circle. Then I use agent.destination to move it
Honestly what I want to know is how can I detect if the AI is stuck outside of my navmesh and then how should I send him back?
I have a patrol system, which consists of a chain of points, and everytime my agent reaches a point it gets send to the next one. The problem is, when I have multiple agents, and they arrive on the same spot at around the same time, they clump together trying to reach the spot, resulting in none of them reaching it.
How would I avoid this?
Either make them not collide with each other or modify your ai not to send NPCs to occupied points
Probably both
How would I detect if a point is occupied? I cant use exact position match, since that doesnt happen when they clump together
And them not colliding would result in a unrealistic feel
How do you handle your points? Are they objects?
I dont recommend using separate variables, make a list instead
or array if you wish
I plan on doing that, its just for testing atm, in the end those patrolpoints will be created dynamically
and hardcoding positions is not the best idea
I suppose you can add a bool property to PatrolPoint class that tells if its occupied
Maybe I can make a sort of queue, that makes them stop like ~1,5 times their own size infront of an occupied point
thats also an option
and if that spot is already beeing queued, just make it ~3 times their size
NavMesh.SamplePosition() will do it for you. Keep your random inside circle part. Then instead of feeding it to setDestination, use samplePosition() to get closest point inside the navmesh first.
@real sonnet thanks ๐ I've solved it now. What I did is check every 2 secs if its stuck/same position then I just set a new path.
Hi everyone can anyone help me how to make Friendly Allies AI??
Hello, I am using A* Pathfinding and I have a left idle and walk animation on an enemy. I have it tracking the main player, and it auto flips left and right, but for some reason the idle doesn't flip. Does anyone know where the code for the flipping resides?
2d game btw
I can see the scale X is changing from a 1 to a -1 whenever it flips. When going right it walks and idles at 1. But when going left it walks at -1 but idles at 1
I have no idea why it's happening
Also, I have no scripts on the GFX for the enemy. So I assume the A* Pathfinding is handling the flipping?
The GFX has just an animator on it
I'm not clear what exactly you wanted me to answer here though
Basically I am not sure what's controlling the flipping of the GFX
I have an idle left and a walk left animation
the walk is flipping perfectly fine
while the idle is just always facing right
It doesn't make sense
I deleted the animator, re added it with just the idle, when It's tracking it's facing the target correctly. But when it stops it's always facing right.
I think that this is more of a 2d question than an AI question. But while I understand what you're asking about there's undoubtedly something that u need to troubleshoot. If you're using an A* asset from a third party you might ask their support.
I don't use Unity's animators for anything so it's not something that I can answer
I think it's most definitely a problem with the AI scripts.
The animator otherwise is pretty straight forward, you put in a left animation and that's just how it is. For some reason, the GFX is getting flipped automatically depending on where it's target is. But, it has inconsistencies and I can't figure out why.
How do I generate 2d ai which increase its spead and rotation speed time by time between minimum ai and max ai count ? Can someone help me ? (The ai code has a public float spead and public float rotation speed)
Ive mostly seen A* examples use grids for their implementation is it possible to use A* without the reliance of grids?
Failed to create agent because it is not close enough to the NavMesh
I am literally using SamplePosition to get a point on the navmesh to spawn the AI, which it aligns perfectly to the navmesh but is disconnected from it somehow.. what can I do ?
.. Really? This is the solution for spawning an AI? happens to be a very common thing in games, can't imagine this is what everyone has to do ๐ค
Hey, I'm going to start working on a rudimentary AI that rotates to follow a player. Would there be any function that can detect and track the player, either through a camera or something else?
For context, it's a space flying game so there's no navmesh I can use
Hello i have a scene which run at 50 FPS but when i add NPC to my game it getting worse
with 50 npc which just wander around in scene with custom controller i get 25 FPS drop
so is there any solution on unity asset store which i can use for characters?
i want to add as many characters to game
Sure you could search the asset store for low footprint wandering AIs for your NPCs
OR use the Profiler to fix the heavy performance load step by step
any specific asset in mind?
I don't. I don't know each asset on the store, and one might be better suited to your project than another. Your call really ๐
Hello i have a question. How can i find the distance to player using A* pathfinding. A* pathfinding creates a line/path to a player and it cant ignore obstacle and base of it it creates a path to find the player and i want to messure it
If you still need to know, you just create a path then do path.GetTotalLength();
ok ty
Hi, I don't know if I need to use a* path finding or nav mesh from Unity
It's a 2D project when the world is divided in "squares" and I have a 2D array where I have all the positions of the player
If it's a grid, then use A* (or some other tile based algorithm).
okay thank you
All efficient pathfinding solutions use A* or a derivative of it. A* works on any graph but optimized implementations exist for all sorts of topologies. NavMesh is just a Grid where all tiles are triangles.
When I set an object to be Navigation Static, does Unity use the object's mesh, or the colliders you've defined for the object to calculate the navmesh? I have a lot of small trees with thin capsules for the trunks but it seems like the navmesh is taking the whole mesh into account in spite of the trees not having mesh collider on them.
Yes, it's based on the mesh geometry.
Hello !
I was implementing a FSM based on SO and realized I was basically doing what this unity tutorial is doing : https://learn.unity.com/tutorial/pluggable-ai-with-scriptable-objects#5c7f8528edbc2a002053b487
But I'm facing an issue with this approach : since actions (like Patrol) are assets, anything they store will be shared between all AI using the same action. That's why they store any datas that could change in the StateController of the AI (what I called Brain in my project).
Which is...
Strange because the Brain will have to store a lot of values if the FSM starts to grow. Lots of these values will not even be used by the AI. Like why would I store a "currentDirection" in an AI that can't even move ?
I tried an object based FSM in another project, but I hate it since my transition are stored in the states which means I have a LOT of c# files to manage, in the SO approach I only have to create a lot of StateSO for each different AI which is fine, but I lose the fact that each action and transition is an instance of an object and thus can store temporary datas.
I know you can use CreateInstance of a ScriptableObject, but it feels hacky and not the way SO where supposed to be used.
But is there any other way to represent states/actions/transitions than either plain class, SO or GO components ?
Its weird ive been trying to see good examples of waypoint graph though most A* uses grids and stuff
I disagree with using CreateInstance being hacky, but you can certainly achieve very similar functionality by storing the logic on a SO, storing the data on a plain C# class that you create an instance of for each AI entity, and passing that data into the logic. You need to store the data somewhere.
With your example of the "currentDirection" not being needed for an AI that can't move, that seems like a problem that either interfaces or components could solve well.
Very roughly:
public abstract class FMSAction<T> : ScriptableObject where T : IFSMData
{
public abstract void Update(T data);
}
public interface IFSMData { }
public interface IFSMMoverData : IFMSData
{
Vector3 CurrentLookDirection { get; }
float MoveSpeed { get; }
}
public class FSMMoveAction : FSMAction<IMoverData>
{
public override void Update(IMoverData moverData)
{
// do movement
}
}
public interface IFMSAttackerData : IFMSData
{
Vector3 CurrentLookDirection { get;}
float AttackSpeed { get; }
}
public FSMAttackAction : FSMAction<IAttackerData>
{
public override void Update(IAttackerData attackerData)
{
// do attack
}
}
// your actual AI actor fills this in and passes it to the FSM
public class FMSMoverAttackerData : IMoverData, IAttackerData
{
public Vector3 CurrentLookDirection {get; set;}
public float MoveSpeed {get; set;}
public float AttackSpeed {get;set;}
}
So if I understand correctly, you think that any instance specific data should be stored in a component of the AI (like the Brain component), with maybe using interfaces for optional data. In the unity lesson that I heavily based my implementation on, they store all instance specific data in the StateController (like current target, current waypoint, etc...) and the Actions that actually need these info simply retrieve them so I guess it's close to what you are saying.
(Sorry for the late answer)
does anyone know a tutorial or something on 2d topdown pathfinding? i checked out a* but since my game has a mix of non tilemap objects and tilemap objects it didnt work
i have a question. Does anyone know how i can make an ai follow the player (the enemy should have gravity, so i wont use the brackeys video, the enemy should also jump if it needs to.)
2d?
Yes
lol
username checks out
is there any way I could get the NavMesh GameObject that the NavMeshAgent is currently on?
NavMesh or NavMeshData to get navmesh data in use, I don't think there is a way to get an object the navmesh is on beyond say sampling a position and sphere casting around it
Is anyone interested in helping me with an AI game? I already have an idea, itโs for a school project of mine, please DM me. ๐
It kind of sounds like you want someone to make a game for you..?๐
No, I wanna make a game but Iโve never made an AI game so idk how it works, would like someone to help me haha
Well, there are plenty of ways to implement an AI. Hard code it, use State machines, behavior trees, planners, machine learning. Do some research and ask if you have specific questions regarding the implementation.
Alright thanks
can anyone please tell me how to make a plane block the NavMesh?
the case is an island with a sea around it
the submerged parts of the island should not be walkable
Hi i'm currently dissecting PixelCrusher's QuestMachine's procedural quest generation, which is a type of an Action Planner
Just wondering what's the difference between AP and Utility AI?
QM's AP can achieve the sims behaviour, calculating their urgency and figure out a plan to relive that. But what about Utility, which i heard the sims is "officially(?)" based on?
If I understand it right, strictly speaking AP and Utility don't contradict each other. Utility ai means that an action is selected based on some formula calculations. Planners mean that the ai can plan a sequence of actions. So, Utility can be a simple state machine, where there's only 1 state changed planned ahead or a more complex planner that calculates a "path" of actions based on their utility. I've used an asset implementing GOAP(called ReGOAP) a few years ago and it was doing exactly that.
Yep cool. That's what i thought too
I guess Utility is more short term, what is the single action that scores the most and do that
Whereas planners sequentially does this and tracks the world state as it makes the plan, and therefore a heuristics gets relevant to come up with the sequence of actions
I'm attempting to make a playercontroller that uses navmesh. My canMove bool is always returning false and I cannot figure out why. I tried using a normal navmeshagent and it works fine. Tried with both a terrain navmesh and a navmesh component. Any help would be appreciated. ```
private void Update()
{
Vector2 input = move.ReadValue<Vector2>();
if (_Data.state == GameState.explore && input != Vector2.zero)
{
Vector3 newMove = new Vector3(input.x, 0, input.y);
MovePlayer(newMove);
}
}
public void MovePlayer(Vector3 value)
{
Vector3 newPos = transform.position + value * Time.deltaTime * moveSpeed;
NavMeshHit hit;
bool canMove = NavMesh.SamplePosition(newPos, out hit, maxStepSize, NavMesh.AllAreas);
if (canMove)
{
transform.position = hit.position;
}
}```
Alright, turns out you need to make it the thing you are moving the exact height of the plane. so I have to have an empty object as the parent with the move script and move the character visuals to a child.
there are probably things you could do to raycast at start to move to correct plane for navmesh but I don't know them.
Hi, I have a hex-based procedurally generated map and I want to generate a NavMesh. Now seperated hex with walkable biomes (plains, mountains, etc.) and water to separate layers. I read this case requires additional NavMeshComponents from Unity Github https://github.com/Unity-Technologies/NavMeshComponents but maybe there's easier way to do this?
check out A* project it's well worth the investment best around for what it provides, and it provides a lot- including hexagon support.
could you link this project here, please?
@stable bane
https://arongranberg.com/astar/
hm...89โฌ sounds like overkill for graduation project :/
Try the free version:
https://arongranberg.com/astar/download
I'm not exactly sure how limited it is but it's better than unity's built in by a long shot.
actually, here is an exact breakdown:
https://arongranberg.com/astar/freevspro
*seems to support hexagons in free version
looks cool, but don't see in documentation how to use it via script to generate a navmesh at runtime after map generation
https://arongranberg.com/astar/docs/createrecast.html auto generation is available only in Pro version :/
I know you can update the graph in game for the free version, that link is separate-
but if you are wanting an easy fix I would stick with what you know in unity's navmesh, going the component route
I don't know how that works but I'm sure it has docs covering that, at least on youtube.
I have to repeat the question I need to do this today-tomorrow, and I cant find the answer: "can anyone please tell me how to make a plane block the NavMesh? The case is an island with a sea around it. The submerged parts of the island should not be walkable"
How do you go about creating an AI like in a sports game? (but less sophisticated)
As in:
- Not Navmesh/pathfinding
- Has to be smart enough to defend itself
- But not super smart, player should still be able to score after all
What topics should I be looking at?
Some keywords: Behavior tree, goal oriented action planning, utility function
ร pretty neat behavior tree (and more) for unity with graphical interface https://assetstore.unity.com/packages/tools/visual-scripting/nodecanvas-14914
Iโd recommend Focusing your research/design on ways to make the ai as simple as possible while appearing intelligent, particularly for sports you can get away with extremely simple, purely reflex based behavior without any explicit team coordination. Similar to how bee and ant colonies organize themselves, or even simpler.
Thanks a lot! ๐
There's a free asset on the store called "navmesh cleaner". It allows you to specify areas that should be removed from the navmesh. Although I'm not sure if it's gonna work in your particular case. But it's worth a try...๐คทโโ๏ธ
yeah, I guess I'll have to do it manually one way or another. thanks for the information
Just wanted to share something potentially interesting to this group! Adam Myhill from Unity has been working with the folks from Transitional Forms AI, who are using A.I. and Unity to create customized immersive experiences that merge content creation, real-time audience interaction and machine intelligence.
They created something called Dinner Party, described as the following:
Built using a combination of Unity, GPT-3, and Replica, dinnerparty is a multi-model narrative production platform that allows content creators to easily โseedโ dialogue, audio and visuals that generate the most strangely compelling content in real-time that can be used to showcase whatโs itโs like to co-create with machines.
I'll be joining them as a guest director on their Twitch stream to make some hopefully absurd, strange, live animated content with artificial intelligence! We will even break down how they make all of this Twitch interaction work in Editor!
Come by to say hi at 2pm ET over on https://www.twitch.tv/dinnerpartyai
More info about Dinner Party: https://transforms.ai/dinner-party
https://www.twitch.tv/videos/1170449071?filter=highlights&sort=time
Join us every week as we explore the hilariously random and absurdly strange possibilities of generative, live storytelling through the magic of artificial intelligence! Want to direct a show? Like us on social & email us at social@transforms.ai.
dinnerpartyai went live on Twitch. Catch up on their A.I. An Experience With Artificial Intelligence VOD now.
What kind of math do I need for AI in game dev?
I want to brush up on my maths.
Any recommendation on books/resources would be greatly appreciated.
It depends. Most ai is not exactly math - it's algorithms. Navigation might be slightly related to vector math. Other than that can't think of anything specific.
Ah, I see. Thanks for the help.
checkout the unity official course
I was literally researching it yesterday and found this official course/path
pretty good imo
In this course, Dr Penny de Byl reveals the most popular AI techniques used for creating believable game characters using her internationally acclaimed teaching style andย knowledge from over 25 years researching and working with games, computer graphics and artificial intelligence. Throughout, you will follow along with hands-on workshops design...
@uncut dagger Thanks a lot mate! I'll check it out for sure.
someone know why i have this warning
i have a question
how come my ai prefab is broken
its there
doing its job
just invisib;e
idk, probaly not important because warnings arent bad, dont stop your script.
This is so cool, working on a tool that utilizes GPT-3 & Unity for environment automation ๐
Hi! I'm making an RTS prototype and would like to see if a building (a GameObject that will be a Nav Mesh Obstacle with a predefined Bounds.size) fit in the navMesh and without colliding with Nav Mesh Obstacles. What's the best way to achieve this? Been trying to find a good answer by reading up on the navMesh docs, but haven't been able to so far.
Can someone recommend any good, comprehensive resources to learn AI that aren't the pinned ones?
its a field in active development, the common approaches like behaviour trees, GOAP etc are found in the book series "AI Game Programming Wisdom"... later developments you find in GDC talks on youtube. A good general intro to AI (not game specific) is the book "Artificial Intelligence: A Modern Approach" by Russel, Norvig. That book covers all the theory and principles on all the different approaches to AI that have been discussed in academia or used in practice. For the underlying graph algorithms like A*, there is "Introduction to Algorithms" by Cormen, Leirson. More advanced algorithms are best discovered via conference papers/talks. A good intro on ML relevant to games is "Reinforcement Learning: An Introduction" by Sutton, Barto.
Thank you i'll check those out
So I have a bit of a problem. I want my AIs (or guards) to go through the door, however they're just phasing through them. I want them to go down the red path but they're taking the blue path. I've tried setting various objects as obstacles but that causes them to not be able to go through the door entirely
Check your Navmesh, it might not be corresponding to the actual geometry in which cas you'll have to rebake the Navmesh.
Yeah we got it. (Mostly). Somebody forgot to set the door frames as navigation static
Hi, I am having a weird issue with navmesh agents.
No matter if I use set destination or calculate path manually, the path is always only partial and doesn't lead to the destination.
However, the path should be possible and I can walk there manually when continuously sampling smaller stepps along the way.
Has anyone encountered this issue? Only getting partial paths when it should be possible to get a full path?
I'm looking to spell words with gameobjects / transforms / cubes by lerping each object into position to spell, much like a drone show. Are there any resources out there where I can start looking how to do this?
Hello I have an issue with the nav meshI come with a doubt about Unity, maybe you guys know something
Do you know how I can have two different agents in the same navmesh in unity? Let's say one that is an enemy and another one is an npc that follows you - now, I have an error where if I use one type of agent everything works but if I use another (with everything the same except the name) I get - "SetDestination" can only be called on an active agent that has been placed on a NavMesh - but it is using the same object only i am changing the navmesh agent in the inspector(which as said, has the same properties as the other one, the only difference would be the name of the agent)
I looked for a solution but it goes like "just change the values of the agent", it seems that for one navmesh you can only have is a single agent: /
is the same Game Object
nav mesh settings
I want to work an some ai for my game but Im running into an issue. I want to do a searching related algorithm like minimax or monte carlo, but this requires being able to test out actions before making them. In order to do this I would nee to simulate what would happen with an action without this actually affecting the game state. Are there any ways of doing such a thing? I normally could create new objects with the same data as the old ones and modify those but unity doesnt allow the use of constructers with objects that extend monobheavior, so I cant create new objects. Could I have a unity object hold an instance of an object without it extending monobehavior? like have a script attached to it that is just a normal c# class and have it hold the data of the object while a seperate script that extends monobehavior controls the movement of the script?
For such a thing you should separate your game state completely from monobehaviour such that the gameobjects in your scene will only be views of that state but not store it. Otherwise the whole idea of having multiple simulations running in parallel is impossible/nightmare.
great help unity u':
bump
Thanks, I figured this might be the case and started on doing that.
hi there... is there any way to bake navmesh on a curved surface like this?
Why use the navmesh for this?
I just finished my Ai asset for simulating emotions! PerSim - Personality Simulator. I used research of psychologist James Russel and others for defining the emotions digitally. PerSims can experience a range of emotions to varying degrees at the same time and just might be the most diverse and accurate emotional system for a game. Users can limit the emotions their PerSims can feel or even create their own emotions if there is not enough for your game. It is submitted to the asset store and I'm awaiting approval. If you would like to follow my progress you can follow:
twitter.com/logicandchaos
facebook.com/logicandchaosAssets
If you have any questions or would like to be put on the mailing list to be notified when it is available, email logicandchaosassets@gmail.com
Is it possible to manually trigger updates of a NavMeshAgent?
I figured something out I guess ๐ค
Failed to create agent because it is not close enough to the NavMesh Anyone know how to solve this? When I create a NavMeshSurface
Possibly have an invisible 3D object that contains the navmesh agent and use it like that
That worked for me at one point
For the AI
Not the surface
Is there a way to use Navmesh pathfinding without using the navmeshagents automatic movement?
If I simply want to get a vector from the first and second path node to use as movement input vector for say, a rigid body force in said direction or character controller move?
Okay turns out I need to use NavMesh.CalculatePath to get the Vector3 corners of the path
Only question is this parameter. What does this mean?
And another thing, how 'precise' does the vector positions for calculate path have to be? I assume that if you try to calculate a path from a position that is mid air it wont return anything, but how close does this vector position have to be to the navmesh?
@foggy heron There's also https://docs.unity3d.com/2021.2/Documentation/ScriptReference/Experimental.AI.NavMeshQuery.html that may help if you hit limitations with the older API.
I believe the routine used to find nearest navmesh is pretty good at finding navmeshes directly below
SamplePosition?
Just any world position you pass into these methods in general
I believe they do more than just SamplePosition to avoid having to use large search radiuses
The nearest point is found by projecting the input point onto nearby NavMesh instances along the vertical axis. This vertical axis has been chosen for each instance at the time of creation. If this step does not find a projected point within the specified distance, then sampling is extended to surrounding NavMesh positions.
https://docs.unity3d.com/ScriptReference/AI.NavMesh.SamplePosition.html
Oh seems like SamplePosition already does the vertical finding, so yea, they probably just run everything through SamplePosition
Yeah I were just wondering because I assume NavMesh.CalculatePath doesnt return a valid path if it's a position in the air, or something like that, so I thought the 2 vector arguments had to be precise
I meant that I don't think those methods assume the position to be super valid
Hi, we're making a game where the Ais have to follow the player, and we used the navmesh to do it, we've tried to use the navmesh offmeshlinks generated automatically with the navigation component but it seems like the agent can drop from the platform but could not jump to it, cause the offmeshlink has directed the platform below it and not the other way. Is there a way to make it work also the other way ?
https://pastebin.com/czZfDHuh anyone know where to go from here when implementing a minimax algorithm for AI?
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.
so i want to make my own ai pathfinding script what's the easiest way of doing it?
or at least if there is anything that could help me
The easiest way would be to not make your own pathfinding
but a simple google search finds a lot of resources
i tried other scripts but they were a bit too efficient with pathfinding
What do you mean by AI pathfinding script? What should it do?
for my game i have this ai that is very basic at the moment..i have pretty much everything but pathfinding working so if the player has a wall between it and the enemy it will just attempt to follow it through the wall
https://cdn.discordapp.com/attachments/225559761729486848/914611889080762428/ai_test_1337.mp4
basically i want to mantain the movement system i made but still have pathfinding working which is something i havent found a fix to with other pathfinding scripts/algorythms(not sure on exactly the correct name is) such as A*
Sounds like you just need to write your own path navigation
Odds are more or less any pathfinding system would work as long as it supports 2D on whatever axis you are using
You can generate paths using Unity's pathfinding without using their agent to navigate the path
that was something i was working on in the meanwhile but i'll try using unity's pathfinding although i'm not familiar with it
how do I make navmesh agent stop at a nav-mesh-link so I can trigger certain events like a change animation function ?
anyone know how i should start making an ai that learns how to play a game based on three inputs. The positions of its character, detection/position/speed of projectiles and enemies and speed of itself and what weapons it has???
Keywords are minimax and q-learning
Need help with my Interceptor/Drone code. Works fine while the target is stationary but as soon as the target starts moving the drones just start clumping up at the target's position
Depends on what you mean by ai. If you just want like basic cpu's you can just code in behaviors that it has based on those things. If you actually want a competent ai, then minimax is the easiest, but doesn't work particularly well for real-time games.
Ok guys i have a big question for y'all. So I was trying to make a Custom NavMesh based on the A* pathfinding algorithm for 3D maps . All I could actually find on Google would be either 2D where the scene wouldn't have any type of 3D maps it would just be a flat surface with walls and stuff or it would be using the navmesh from unity (which is not my purpose). Does anyone have any idea how I could do it? (I've built a system based on various types of getting a navmesh, but for some reason it's not fully working out.) If anyone can shine some lights i don't mind giving out the files or even going on a call and show everything I've done so far.
Those are the two most common cases; outside of that you really need to define the parameters of what you DO need..
What do you mean?
like i don't wanna make an overcomplicated Navmesh like unity has
mine should work like a node based one but for some reason my nodes ain't properly right?
how difficult is it to make a waypoint AI that doesnt use pathfinding but still avoids obstacles well enough?
difficulty depends entirely on the desired quality of the avoidance (simple case would be something like: if raycasthit, turn 5ยฐ right, repeat). you can also bias those iterative direction changes by a general heading the agent should take to allow them to stay on track or inside a given range... if you add multiple agents you can use flocking behaviour (i..e agents looking at what their nearest neighbours are doing) to enable larger scale avoidance/flow...
im looking for smart enough to not get stuck all the time but dumb enough to not be boring
ร lot of seemingly advanced/complex movement behavior can emerge from very primitive/simple reflex agents (no memory and world model), examples would be team sports games, wildlife simulation, bee hives, ant colonies, โฆ
Are you familiar with Elite Dangerous? im tryting to recreate a similar spaceship movement but for example racing through a canyon (still no gravity)
Im thinking of doing it all using AddForce and AddTorque but im not sure how to accurately make it turn without overturning and just spazzing out
Maybe add a self correction mechanism that counterbalances the avoidance. Inertial dampening and drag
hmmm
yeah im not exactly familiar with these things
last AI i did was more or less 2D plane and used a big chunk of the pathfinding agents
you can think of it like a little brain of a bugโฆ for every excitement (avoiding) add a desire to inhibit further change (moving straight)โฆ. That balance can be as simple as a float you add/sub โฆ and use as โactionโ budget
sorry, thatโs all from general agent theory and robotics
the only way i can think of doing what im looking for is to do imitation learning using ML...
There may be some lectures in it on edx
and i dont feel like wasting 3 more days trying to make it work and not get anywhere
ml here is like using a nuclear missile to squash a bug
perhaps, but it adds this sort of randomness to things that make it feel better
thatโs a nuclear war waged on farmers with pitchforks
lol
ml just feels soft because it is a stochastic processโฆ you can add those without going full ml
if you add some simple or gradient noise to your calculations you get the same fuzziness
yeah im just not familiar with AI that much so i cant figure out a way of doing anything near as good
right now the only way i can think of doing it is adding way more waypoints than i was initially thinking so they dont get as stuck on terrain and obstacles
ah also adding a slight random range outside of the actual waypoint nodes so not all of the AI goes for a single point and just bunch up
that veers into navmesh territory
huh?
what do you need your ai-actors to do... how should their behaviour look/feel like
if you solve obstacle avoidance via waypoints thats basically a what a navmesh does (in effect)
but you dont need navmesh and your waypoints should be waypoints
since its in space you'd do what a bird would do
fly towards waypoint but if there is no direct path, steer to the side until there is a clear path again, then if after some time there is still no clear path, pick a random direction with bias to the next waypoint and fly there
not space exactly, but evne in space it will have to traverse asteroids
now you make that raycast only look a few seconds ahead and not the whole way and you should get organic looking behaviour
thats the thing though; different speed would have different reaction
if your obstacles are compact (convex and fit well in a cube-shape) avoidance doesntt have to deal with pockets/cul-de-sacs
ill basically have it hardcoded to work only at X speed
example of what it needs to traverse
speed can be handled via modifiers to turn rate/acceleration etc
at what altitude?
in the canyon?
yup
using ML i added it so it doesnt go above X height, and to try to be above Y height off the ground
you could do what fies do: raycast left right and forward... use the L/R raycast to steer to the middle of the canyon and the forward one to detect obstacles (may need to be more than one raycast for each direction
๐ค
(flies compare the relative velocity of what they see in their left vs right eye to steer such that both eyes see the world moving past at the same speed)
weird
imagine the experimental setup in the lab that figured that out
haha
fly on a stick
if you use ML you'd just feed it a similar type of info and it just figures out how to do it without you having to think about the calculations behind it
ML is essentially "lets fix the function with magic"
oh using ML i'd probably have to set up the waypoints so that the next one is always in direct sight of the previous
yup one reason i went with ML is because of how supposedly easier it is to do stuff ๐
and its interesting to play around with and see it learn
but god damn sometimes it just will not learn anything at all even though it should
im also having weird issues where the actual AddForce is frame-dependent even though its called in FixedUpdate....
the whole physics might be frame-dependent actually, not sure
make sure your calculation of the pyhsics happen in sync with fixed update
its easy to have little value-bugs when polling input/state in Update() and using that in FixedUpdate
is this channel also for navmesh problems? somehow unity generates this, with really strange nav mesh polygons
any idea how to fix this?
are u using this option?
i'm using the github version for 2020.3 - where's this option?
changing the option doesn't change anything
did u rebake the navmesh?
yeah. i use the navmeshsurfaces, because it's for dynamically created meshes
try to avoid mesh colliders unless absolutely necessary
absolutely necessary in this case
well cant recommend anything other than trying if it has the same issue with the unity package one
can't seem to use that with 2020.3
and why is that
navmesh has been up for like 5 years now
dont think its changed much
well
so, only 2021 has this Add package by name
i'm using the github version instead
which had the last update a year ago i guess?
typical Unity ...
well, that's still the github version i already use
oh wow, it works with the name too. thanks!
seems they changed the namespaces?
or did they remove NavMeshSurface?
this doesn't seem to work at all
NavMeshSurface is just missing
...do i have to install the github version still? or what's happening here
what a mess
i'm going to assume it just doesn't work with 2020.3. i really can't get it to work
thanks Unity, once again you make everything needlessly complicated
I use nav mesh agent and my zombie try to reach the player position but instead of try to get around they gang bang with other zombie in front of them, how to improve that ? Like get around for take the other side or just don't move if they cant reach the player position because other zombie are in circle around the player.
https://streamable.com/nhfu4e
private void Chase()
{
if (!_navMeshAgent.pathPending)
{
if (NavMesh.SamplePosition(_targetDetection.Target.transform.position, out NavMeshHit hit, 20f, _navMeshAgent.areaMask))
{
_navMeshAgent.SetDestination(hit.position);
}
}
}
besides saying "it's a feature and not a bug" possibly try and up the mass of the player, so they push it less? Unless that messes with other physics stuff you're working with, in which case maybe lower the mass of the zombie, that way it'll push less with physics.
the zombies will still push eachother, but the player will not be moved around as much
I don't have rigidebody on player
And the zombie will still not get around for a avoid other and circle the player @dark willow
Hi All,
I'm trying to use NavMesh.CalculatePath(...) for a second agent type. When I set the agent type Id on the filter I get the following error:
NavMeshBuildSettings for agent type ID: 1 wasn't found
Where do I need to set this up? At the moment I have a NavMeshSurfaceComponent which has NavMeshData assigned to it with the corresponding id. I can't see anyway to specify this Id in the agent settings.
Any help appreciated ๐
I just noticed - there is another Id on the data that I can't change...
Using this autogenerated id seems to fix the problem โ
If anyone knows where this comes from, would appreciate knowing ๐
hi all i have been working on this script and cant seem to work out why it not working. i have it on my enemy and i also have a nav mesh agent on it too, so can someone please let me know what i have done wrong. https://www.toptal.com/developers/hastebin/jojanugofu.csharp
Set the priority of the nav mesh agent based on the distance from the target. Then the ones that are close won't move and the ones further away will try and find a way around.
I don't think they go around they just overlap agent
@proud radish
I tried with agent with 10 they just go forward and mush agent with 50 on the side
He dont get around
Vid2Actor looks cool paper for reconstruction of 3D differential animation
motion re-targetingย
from a video without noise is a thing
So I know next to nothing about pathfinding and Im trying to decide whether or not navmesh is the route I should be taking. Ive got units that will need to pathfind their way around a moving ship, is there any consequence to having a navmesh moving around? Or does it work just fine?
I've set up a few enemies to chase my player through Unity's Navmesh, but it doesn't really work. They move just as intended on flat surfaces but they just stop as soon as they encounter a ramp. It kinda works below 6-7ยฐ, but anything steeper than that is treated like a wall. Only by the agent though, the navmesh itself looks like it should. The whole baking process with max slopes and such works, it's just the agent itself that's causing problems. Not using rigidbodies or anything. Anyone got a solution?
Is it a good practice to use State Machine Behaviour or SceneLinkedSMB for AI?
I didn't seem to find any fresh info about working with AI behaviour and animations in pair, besides this two things. So any advice or link would be appreciated.
I personally don't think it is a good practice, as Mecanim was not really built for AI purposes, so here and there you'll find places where it could be limiting your AI
Also, AFAIK Mecanim didn't receive any significant update on the past years? I may be wrong. But it seems dangerous to rely in that, IMO
SMB also doesn't allow you to extend how the state machine works. So if you find a hard limitation, you'll just have to live with it and maybe have to add workarounds for it to do what you need, and Mecanim would definitely hit you with limitations if you need some advanced AI
I understand the value that it holds by offering you a visual editor which shows you the current state and stuff like that though
So I would say that it can be considered for simple prototypes, but I would definitely say that it is not a good practice...good practice would be to study/build your own FSM for actual AI purposes (lots of tutorials on that, even Unity officials https://www.youtube.com/watch?v=cHUXh5biQMg&list=PLX2vGYjWbI0ROSj_B0_eir_VkHrEkd4pi), buuut doing an editor (if you want one) adds a lot of work and tooling knowledge, so it depends on your main objectives
If you still want to research though, I've found some videos on youtube by searching for unity3d state machine behaviour, it just makes me uncomfortable that some videos say it's "Advanced AI with state machine behaviour" while it's definitely not how advanced AI looks like, so I suggest you to take care while evaluating
Thanks for the explanation! I've actually found FSM example by Jason Weimann ||https://www.youtube.com/watch?v=V75hgcsCGOM|| which looks as a good starting point for me, and going to stick with that now i think.
Build bots for your Unity game with a powerful but simple to manage state machine built completely in c#. Learn how to use the state pattern in unity, building an AI to control harvesting bots that could be used for an RTS, building game, shooter, or anything else. We'll dive into transitions, states, ai, bots, and how to hook it all up in a cle...
Great! Seems like a good starting point indeed. Good luck with your FSM adventures ๐
lol
Hi, im using a Behaviour Tree for my AI, but when the AI dies, the Behaviour Tree still runs some AI code, which gives me errors
ZOMBIAI
How can I create something like, 10 AI GameObjects around the player and them after they're getting far away from him to make the game also run smother?
Si if I place trees and make a mountain with the unity terrain tool, will the ai that is from unity itself avoid those trees an mountains?
Ty
Baking navmesh creates strange spots for places the navmesh can't go where nothing exists
little invisible obstacles--everything else in the scene is disabled
maybe I'm searching for the wrong things but I've found forum posts and other posts about this but 0 answers as to why
like even when it's perfectly level there's just a hole in it for no reason
Is this an imported terrain?
yes, do you think it's retaining the old terrain data?
I think that spot is a clump of inverted poly normals. Fix that through blender or any other 3d modelling software
hmm if the normals were flipped wouldn't it not render this direction?
it does render, it's just when I bake a navmesh it creates this hole in the navmesh where no object exists
Oh,
Eeh I don't know enough about baking yet, sorry.
Perhaps there's some tolerance type sliders you can adjust
So far I've cranked the agent settings to be able to go over almost anything and leveled the terrain perfectly flat. Still puts a hole there haha
No idea what causes your problem but as a workaround, you could add a plane over that hole, make it static, bake, then turn off the renderer. But clumsy but if you can't find another solution it may be a workaround.
haha that does sound silly but I'll see if that works as a temporary (permanent lol) fix
There are pins in #๐ปโunity-talk and #๐ปโcode-beginner. This channel is for AI questions only.
Hello, I'm trying to let a nav-mesh-agent search the player. But the problem is that it chases the player inmidiately and won't stop chasing when the player is out of sight. Does anyone know why this happens?
using UnityEngine;
using UnityEngine.AI;
public class enemyMovement : MonoBehaviour
{
//PlayerDetection
Ray ray;
RaycastHit hit;
public LayerMask layer;
//General
bool destinationSet = true;
GameObject player;
//NavMeshAgent Settings
NavMeshAgent navMeshAgent;
int patrolingSpeed;
int chasingSpeed;
//Walkpoint
Vector3 walkPoint;
public int walkPointRange;
public LayerMask whatIsGround;
void Awake()
{
player = GameObject.Find("Player");
navMeshAgent = GetComponent<NavMeshAgent>();
}
void Update()
{
if(destinationSet == false)
{
CheckWalkPoint();
}
if (destinationSet)
{
CheckPlayer();
}
navMeshAgent.SetDestination(walkPoint);
}
void CheckWalkPoint()
{
Vector3 distToWalkPoint = transform.position - walkPoint;
if (distToWalkPoint.magnitude < 1f)
{
destinationSet = true;
}
}
void CheckPlayer()
{
Vector3 playerDirection = player.transform.position - transform.position;
ray = new Ray(transform.position, playerDirection);
if (Physics.Raycast(ray, out hit, layer, 15) == player)
{
Chasing();
destinationSet = false;
}
else
{
if (destinationSet)
{
Patroling();
destinationSet = false;
}
}
}
void Patroling()
{
float randomX = Random.Range(-walkPointRange, walkPointRange);
float randomZ = Random.Range(-walkPointRange, walkPointRange);
Vector3 tempWalkPoint = new Vector3(transform.position.x + randomX, transform.position.y, transform.position.z + randomZ);
if (Physics.Raycast(tempWalkPoint, -transform.up, 2f, whatIsGround))
{
walkPoint = tempWalkPoint;
}
}
void Chasing()
{
walkPoint = player.transform.position;
}
}```
Would anyone know whether there is boolean variant for m_ResetParams = Academy.Instance.EnvironmentParameters; m_ResetParams.GetWithDefault("QuickMovementScalar", 0.0f);
Its a pretty nice method, where the value is set to the default float when there is not value specified in the config file. I am trying to make it work for booleans, so I can specify them in the config .yaml file
how can i make it so the ai only follows the path? now it will walk in to the trees (off the path).
already baked
How do i setup my behavior tree so it will wait for an unity animator to finish animation in a task? I'm trying to do that for the task that represents attack with a cooldown and can't be interrupted. Sounds like a simple thing but I've kinda stuck on that one...
are you familiar with animation events? https://docs.unity3d.com/Manual/script-AnimationWindowEvent.html I often use animation events to get callbacks when an animation finishes (terrible system, but its the best that I've found...)
Make a bool animating variable that lets the BT know when the animation is running and respond accordingly?
yeah, animation events is also everything that I've found
besides dumb check of animationInfo.IsName("name") && animationInfo.normalizedTime >= 1
which doesn't actually work that well in behaviour trees
but i start gagging after the thought of calling methods by a string name....
what is object field here by the way?
yeah, agreed.
if you select an instance of an object with the animation clip in its animator, you get a drowdown of valid functions
which is better, but still just as sketchy under the hood
Did you tried using StateMachineBehaviours to dispatch normal C# events OnStateExit()? Maybe through some kind of singleton manager inbetween... Just got this idea.
It works just fine, but there is also some cons to it, Animator.GetBehaviour<>() doesn't work with interfaces....
OMG there is an AI channel... YAY
If anone knows if there is an ai for unity that alows an entiy to interact with the envirnment, consume resources, then make use of those resources, based on certain restrictions, please PM me.
Does anyone know how to get a navmesh agent to move by hopping around??? AddForce to make him jump doesn't seem to work because a nav mesh agent appears to stick to the navmesh constantly and refuses to go in the air.
Does anyone know a solution?
NavMeshAgent and Rigidbody don't play nice together. My approach would be to have a parent object with the NavMeshAgent and a child with the MeshRenderer, etc, that does the hopping, procedural animation style. That way the parent can stay glued to the nav mesh while the child moves up and down for the hopping motion.
But that way the navmesh agent can't jump up to higher ledges, and there is only a global stepheight that affects all navmesh agents.
How to make two different nav mesh agent sizes????? The unity navmesh system doesn't seem to allow that AT ALL. So I can't have one NPC be bigger than another because he will clip inside walls because he's treated as the same size as the small NPC
Apparently I need to download a custom package for it from github?? Why is this not included in unity by default? I can't find it in the package manager even though the github page says it's there (yes "show experimental packages" is turned on, and I'm on LTS long term support version). Apparently it's only for the 2021 non-LTS "beta" versions? So I have to get it from github?? And how do I use that package to make different navmesh agent sizes? The documentation is messy
Can anyone help?
Yes
Where is the documentation for the navmesh extras package made by unity?
How do I use it to make a navmesh for multiple agent sizes???
Search on youtube there are some tutorials referencing the github material.
Navigation tab > Agents > Add a new type ?
And Relax. nobody wants to help you when you seem this impatient ?????
Yes, you can still jump to ledges.
https://www.youtube.com/watch?v=dpJUc_BpChw
This is doing my head in. Anyone experience navmesh carving around objects that have no obstacle component on them?
Incredibly difficult problem to google. Conflicting keywords I guess.
Okay, for the record I fixed it. Though I'm still a little surprised and shocked that you can carve a navmesh without an obstacle component. I changed the navmesh surface to use the geometry of "Physics Colliders" instead of meshes. ๐
carved dynamically (at runtime) or during baking?
If at runtime, that's shocking. If during baking, another solve would be to uncheck navigation static for the meshes
Yes, I'm calling BuildNavMesh at runtime, once.
Weird, right?
Oh?
if they're navigation static then it carves them out
it thinks they're walls or something
Even though they have no colliders?
nav mesh doesn't depend on the physics system
you could use it without any physics at all
Okay
Good to know. Thank you.
So what's the purpose of the obstacle component. Just additional tweaks I guess.
you can modify the navmesh without rebaking it
put it on a door
or a crate
or w/e
stuff that will move at runtime
not static
Awesome. Thank you.
Does anyone know how to avoid navmesh clumping. My enemy AIs get very confused for about 0.2 seconds when a player enters the red circle area.
They like, freak out, lose the target, recalculate, and the proceed to behave normally.
My NavMeshAgent keeps missing the target I want it to attack, e.g running in circles around it, or missing it completely if the target sidesteps, instead of hitting it. These are the settings. Any tips?
idk, maybe the angular speed needs to be turned up if it's just doing loops around it.
Tried messing with the voxel size in the nav bake settings ? Looks pretty funky having so much point density for fairly simple geometry
Im on mobile but it looks like you need more "tiling" for the navmesh. Like you see how you have so many points anchored to these large grid corners?
If you mess with the bake settings so you get a smaller grid (larger voxels?) I bet you that does something
Hope that makes sense.. 4am just an idea lol
Thank you so much for your reply. Tomorrow morning I'll try it out.
There was a website from adobe where you could download agents and animations... But i can't find it again. Does anyone know which is it?
I think it was from adobe
Mixamo it is ๐
Thank you David, your solution worked.
Awesome! Glad to hear it ๐
Finite state machines are 1000x easier to implement than behavior trees.
Itโs taken me 2+ months to write my own implementation of BTs (ITโLL BE EASY they said). I wrote and wrote automated tests for a finite state machine in 2 hours last night.
I cannot wait for global game jam because Iโll get to talk IRL with some experienced programmers and I can talk about it.
I am a guru at this point
For BTs itโs a lack of clear resources that hindered me. Most YT videos keep it high level (and honestly, you can tell they donโt really grok it). There arenโt too many blogs that I was about to find that described an implementation.
To add injury onto insult, there is a buggy Packt book from like 2017 with a buggy BT implementation that seemingly everyone copies.
But I figured it out. I referenced the text written by ancient prophets (from gameaipro) and I knocked out a BT implementation. Again, lack of detail made it take a lot of time, but now my eyes GLOW with BT knowledge
Omg, I was just flipping back through gameaipro the book and realize I missed something kinda bigโฆ There is a URL to sourcecode that I missed. Omgโฆ Reading through the code here would have really sped me up. Literally I just saw it.
They even have tests in the code. Wow, what a public display of human folly. How much time did I spend that could have been avoided if I had only found this before. Wow
Fsm good for smaller needs.. The more complex the more you wish you have a tree haha. I hate dependant states.. Unnecessary.
Halo is a great example of some nice bt.
Hello! Does anybody knows how to fix A* NullReferenceException: Object reference not set to an instance of an object error? First time using it, confused why error happened
Halo 2 introduced BTs to the industry. Its such a cool story.
Basic enemies are fantastic things for FSMs. Old arcade game agents are great examples of using FSMs
Hello! There is no error in the console, as i see on the video
Or i just don't see it?
There is! https://hastepaste.com/view/T3h1
Here is the error message
Something weird happens to pathfinding
Wait a second, ill just move to the pc, its to hard describe on mobile
I'm back
so
https://www.google.com/search?q=NullReferenceException%3A+Object+reference+not+set+to+an+instance+of+an+object If you search on google( like the link beginning ) you will find the answer easier.
It says this: This error is common to beginners for .NET/C#. This exception is thrown when you try to access a memberโfor instance, a method or a propertyโon a variable that currently holds a null reference. Site: https://stackify.com/nullreferenceexception-object-reference-not-set/
ehhhh @silent saffron ?
no problem.
@silent saffron #854851968446365696 message, The "Before posting" place says that you must have searched at least.
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
i know it may be better to ask us, but i searched too, so i'm not a pro inside errors and such too
How can I make the nodes center? As you can see, it's like on the corners of it.
is this navigation related? third party?
This is A* Pathfinding
The red is the blocks that is used to generate the available path.
The dark red is the nodes, I believe they're called.
And the blue is the space they can walk in.
i can show screenshot of settings; one second
so you're trying to line up the center of your nodes with your tile space?
might be a little unnecessary if I remember correctly how this generates walkable area
unnecessary?
if it works on corners, then the opposite corner will be walkable through
I can't advice you since I've just used this for general purposes maybe it was even a completely different setup that just looks similar
so two things.
I see in the docs nodes have a position property you can access perhaps setting it manually to each tile (iterating through the map or something)
well
so i have a building system
when u place block, it'll find the node closest to that block, and it'll market it as non-walkthroughable.. as shown in picture:
the nodes are split at half of the block, that's the issue, so it's selection is pretty random
right- so you just want those nodes to generate at the center of your tiles
instead of in their own grid which doesn't seem to match your tiles
yes
but originally
i had the node size as 0.5 (instead of 2, as shown in picture)
and this causes each tile to generate 4 nodes, as shown here:
however, like i said, when i place a block, it finds the closest node to it:
is this map procedural or by hand?
I would try to instead of scaling the A* grid itself, take the size that fit into a single tile before and manually generate each node into each tile- because otherwise I don't think you'll get it exactly fitting to your tiles without splitting into a smaller node size like shown
is that possible for your setup?
Procedural.
And can also be edited by player.
Think of Terraria (aka 2d minecraft)
Just a thought, wherever you generate -Tile- at -Position- include in that generation process the Node generation, which I'm sure is exposed by A*
each tile is at a perfect x,y position
such as (1,10), (25,36)
No decimals or anything
I'd think by default, the node would follow the same format
Yes, most likely so, I'll have to check that out.
right.. ok hold on, are there any offset parameters you see? Could
be as simple as offsetting the grid.. because you had the right size, it just wasn't lined up with your grid
Not really...
The "center" just tells that specific graph where its center is.
I suppose this one gameobject can generate multiple graphs (as seen by the "Add New Graph" button in picture)
https://youtu.be/i1Lo_WI_YOQ?t=98
I know it's not the node setup but does include live updates to the grid for your building system I wonder is this the better grid for you?
A simple tutorial on how to configure 2D pathfinding for you game.
Read more here: http://arongranberg.com/astar/docs/pathfinding-2d.php
timestamped at 1:38
showing the offset lining up to the tileset
oh it's the same center as you have there.. hmm
oh no way?
well
no
i thought it did, but looking at all of them, it looks like it got offset even more
definitely looks different than this ^^
changing the scale of the grid results in too many nodes at a position; would it be crazy to scale your tiles ?
i wouldnt wanna mess with my tile generation
I believe in the video Aron has a standard scaled sprite tile 1,1,1
cuz that's a good 100 lines.
compared to this A* is brand new and probably only needs a few touches
i saw the video
ah yeah that would be a pain indeed
i do as well
well without seeing your generation/sizing code feel kinda helpless over here maybe someone in #archived-code-general could help you size your generation to standard sprite size- but that's just last resort.
this looks good
had to set the node size to one
and change the center, as the guy did in the video
and when i place a block
looks perfect! i guess i just expected the red square to be the same size as the area it can't walk through.
but it's not haha
so thanks @stone owl ! all is working now
that's great glad to hear it ๐
I know am posting with the same issue kinda? But today when I reloaded unity, the error message disappeared, but pathfinding still teleports enemy in a specific spot? it seems like [Computation Time 0.00 ms Searched Nodes 7 Path Length 7] suddenly switches to [Searched Nodes 137 Path Length 28? ] What could possibly cause this? I am very new to C# and I tried looking it up online, but still cant find what causes this sudden jump. Does anybody knows what this specific issue is called???
Hi, i had this line of code set up agent.SetDestination(player.transform.position); so that my enemy would move to the player to attack him. After I edited my terrain a bit though he suddenly stopped walking around. I re baked the navigation mesh, I increased the max slope, I made a different gravity script but to no avail. What could be causing this issue?
that snippet you provided does exactly what it's supposed to, so without seeing your code it's impossible to know what's causing it. Post to pastebin so someone here can try help ๐
Well i didn't change anything on the code and besides this is the only line I have for movement. He stopped moving after I edited the terrain from flat to have a little bit of hills and slopes (and yes I re baked the nav mesh and everything was walkable)
Here is the whole script: https://pastebin.pl/view/01e99c3f
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
@upper flare I didnt look the code but you said you made a different gravity script : does it set the position by any chance ? Beginners often make a mistake here
There could be a conflict if you overwrite the position from another script
this is my gravity script
public float gravity;
Vector3 velocity;
CharacterController controller;
void Start()
{
controller = GetComponent<CharacterController>();
}
void Update()
{
velocity.y += gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
}
Ok it's player controlled and you're looking for smthg wrong with an agent so nevermind
im trying to make an animation play with the nav mesh agent and the animation works but not the nav mesh, if i remove the animator then it works, any help?
Yes don't put the animator behaviour onto the same game object you put the animator on. Since it keeps the position of game object in control, while the nav mesh agent moves.
@gritty sable
Reply if it helps!
Hi, i had this line of code set up agent.SetDestination(player.transform.position); so that my enemy would move to the player to attack him. After I edited my terrain a bit and he suddenly stopped walking around. I re baked the navigation mesh, I increased the max slope, I made a different gravity script but to no avail. What could be causing this issue?
https://pastebin.pl/view/01e99c3f
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
Is there a way - preferably built into unity - that I can have a non-static gameobject [eg a piece of a destroyed wall] counted as a 'step' for the purposes of AI pathfinding?
Currently my agents just try and push through the rubble, but I'd like them to - not quite climb, but float up and over smaller pieces of debris
You would have to rebake the navmesh
At runtime to account for the new pieces.
ah damn. i was hoping there was some kind of inverse NavMesh Obstacle
Do you have a navmesh?
That's a navmesh agent. Do you have a navmesh as the error specifically mentions.
like a navmesh surface?
Yes, like a navmesh
When researching the function samplePosition regarding what the max or recommended radius should be, and all I find is whatever the agent height is times 2. My program has really no need for agent height.
What is the recommended limit for this value?
Currently mine is set to 13 when I use it, but I just tried 1000 and saw no differnce in performance.
Also, does warping an agent use this function behind the scenes as well? It seems that when warping an agent outside the navmesh, it will still find the closest available position on the navmesh to a certain extent
any idea for what happened?
(the thing should continue attacking me and following/facing me but instead, it attacks me once and stops)
i will dm the scripts for anyone that is up to help me
oh btw and when it attacks me it gives me alot of errors, like ALOT
somewhere in the script you are accessing the animator of I assume the bug, but somthing about it doesnt exist
or there is a getHit kind of animation that the palyer doesnt have
well i can show you my AttackBehaviour Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AttackBehaviour : StateMachineBehaviour
{
Transform player;
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
animator.transform.LookAt(player);
float distance = Vector3.Distance(animator.transform.position, player.position);
if (distance > 20)
animator.SetBool("isAttacking", false);
}
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
}
}
huh one question do i need to use
using UnityEngine.AI;
```?
soo what do you suggest for me to do?
post it on #๐ปโcode-beginner?
It does thanks!
interesting, now the AttackState get's stuck...
That's a veeeeeeeery broad question. One that can't really be answered in a chat. Also depends on each game, so can't answer with no details like that.
I could say start small, and keep adding/refining until you get an interesting behaviour. But that doesn't really help, right ?
With experience on your games and inspiration from other games/devs, you'll learn how to build more and more interesting AIs
I have a big platform that leads into a narrow platform, and when my navmesh agent tries to go from the big into the narrow he slows down, it doesn't happen when i turn off obstacle avoidance on it, but I don't think I should do that. I've tried making the narrow platform a bit wider which does help but does not fix it. Is there just a minimum width needed for the agent to go on it properly? I'm a big beginner, so I wonder then how do I make narrow platforms the AI can also reach?
whatcha making?
Terraria lol (aka Minecraft 2D).
I was working on making the navmesh to tell the enemy AIs where they can and canโt go
Hello, so ive been looking into enemy ai, and ive decided to use nav mesh agents, the thing i notice with it is that if i set it a high speed for example 100, it takes quite a while to turn back to my character, any settings in the nav mesh agent that could fix this?
dit ben ik ๐ณ . Elke abonee is 1 jaar. ๏ปฟ Hoe oud ben ik=
ai does weird, downloaded the code and used the checkpoints right
In this video series Iโll show you how to create a simple car AI (Artificial Intelligence) in C# Unity which is built for 2D Games but also works in 3D. Download complete project on Patreon: https://www.patreon.com/posts/51162606
With this tutorial youโll be able to make a physics based race game with AI and lots of drifting in no time in Unity...
from this video
Try increasing the agent angular speed ?
Hey I am using Nav Mesh Agent, and when the base offset is set as default (0), it will work, but it clips through the ground, it works all the way from 0 - 3 then at 4+ it just stands still. Could anyone help with this? Thank you
top image is default base offset, bottom is 0.452
First generation of neural network system
I want to use Movenet in unity
I was thinking to use barracuda
I converted tf movenet to onnx and tried to use it gave error
Unsupported default attribute `split` for node sequential/keras_layer/StatefulPartitionedCall/StatefulPartitionedCall/unstack:0 of type Split. Value is required.```
might have better chances of an answer in #archived-machine-learning
thanks
Hi, I've got a little question relating to navmeshes. I have a navmesh imported from another project as a graph, I wonder how can I bake it as a Unity navmesh (if possible)
It appears that we can't generate navmeshes programmaticaly
https://learn.unity.com/tutorial/runtime-navmesh-generation#5c7f8528edbc2a002053b491 @jade nacelle ?
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...
That's mostly used to generate a navmesh when the game runs rather than bake it. It doesn't talk about providing one's own navmesh afaik
Hello, I've got a small problem with A* pathfinding. I'm making a turn based 2D game with tiles and I've included the A* pathfinding and it works fine by adding a blocking layer in the tilemap but how can I tell it to not be able to pass through players/enemies etc that are gameobjects? My problem is that now 2 enemies can stand on the same tile which I don't want to happen.
Can anyone point me to documentation/an example of how I might use Navmesh and a NavMesh agent for pathfinding, but not for the actual movement? I'd like to define my own way and rules of moving the agent, but still use the built in NavMesh and pathfinding tools.
Right- I think I know what you're talking about and I don't think unity's navmesh is capable of accepting custom meshes. What it does allow is generating on essentially whatever mesh you provide it.. so in theory you still get your desired outcome, if you simply run this in editor so it saves instead of in-game.
Hey I am using Nav Mesh Agent, and when the base offset is set as default (0), it will work, but it clips through the ground, it works all the way from 0 - 3 then at 4+ it just stands still. Could anyone help with this? Thank you
top image is default base offset, bottom is 0.452
Oops I didn't realise that, the other image was the monster not clipped in the ground, but not moving
Well I changed the height and it kind of works? He starts going side to side and not even following me
It sounds to me like your mode's pivot is something other than the center of the character
How would I check that?
Okay well I found out another thing, so when the pivot is the center, it spawns in the ground, but it looks like that's because there's an area under the map that has the actual spawn point (image below). I am not too sure how I would change the height of that, but I will try find out. I might need a specific answer for this though.
Do you know 3D software like blender?
One of my friends does
Maybe ask him if he can re-center the pivot point of that mesh.
otherwise it's probably the way you have your object setup, which is the parent which is the child so on
Okay cool, thank you
I somehow fixed it, but now it's going super slow, I change the speed of the navmeshagent and it still doesn't speed up at all, I need to go to bed so I will check to see if anyone replies in the morning.
how do i import navmesh?
You generate it
unity does not translate third party navigation meshes that would be up to you
and by generate I mean- you click a button
filter off areas you don't want, so on
What would be an ideal AI solution of creating a life like simulator 2d. By that I mean you place resources and the people placed choose weather they collect wood, build, research and more by themselves. Almost like worldbox
I was thinking of a state machine but I'm not too sure if there is a better solution
Perhaps you might have some Utility Theory, to reason about the bots necessities in a more mathematical way
In this message, I explain it a little bit:
#๐คโai-navigation message
I also suggest taking a look at the video from AI and Games. In the moment that I marked, he explains a little bit about how it is used on The Sims, which might be similar to your case:
https://youtu.be/p3Jbp2cZg3Q?t=400
Support AI and Games on Patreon to get your name in the credits, early-access and more:
http://www.patreon.com/ai_and_games
Sometimes the AI in a videogame has lots of perfectly valid actions it can take, but deciding which one can be quite difficult. Utility AI is one approach to help solve it, by calculating how useful that action is base...
So I have some tables and chairs in my restaurant
Is there a way I can make it so when my AI gets scared they run through them
This doesn't have the intended effect
(Please ping if you reply)
umm when i click bake in navigation tab, nothing happens just nothing(ping me too if you reply)
I'm trying to figure out how to make a companion NPC for a project, I want it to avoid obstacles and affect/be affected by physics objects and forces, how should I approach this?
I searched for some tutorials but all I could find relied on navmesh to do it and I've seen some people comment out that it isn't a good idea to use it for that purpose
I'm making my own behaviour tree tool and I'm seeing a lot of people with a similar task implement the concept of "blackboard", which acts as the memory of the tree which all nodes can access. I'm really confused as to why this is needed though, why cant the relevant variables be stored on the AI agent's behaviour class? Why separate it into a different class? Seems a bit convoluted to separate it.
You separate it exactly to decouple the concepts, which is simply a good practice in coding. The Behaviour Tree classes can, for example, deal only with branching/acting logic and be agnostic to the maintenance of a memory (blackboard). If you mix their structures and algorithms too much, you'll create dependencies and they will start to bump into each other and chances are that you'll be facing situations where you don't know if the problem is either on the BT or the BB
So the clear separation is mostly because of that but, of course, it always depends on your coding preferences, if you feel like not separating it, then that's fine
I must highlight that the blackboard is not only seen/spoken of in Behaviour Trees. The blackboard is simply the concept of a memory which you can access with a key, and you might have global blackboards (i.e a place where all agents can get shared data from, such as "where is the next team objective position"), you might have per-entity blackboards (i.e it stores data related only to a specific agent, like "what is my current objective")
This is useful not only for behaviour trees. It can be used a lot in HFSMs, GOAPs, Utility Theory, etc...
Now, imagine that your game AI code evolves within time, and then you have some place where you want to consult a position where the agent wants to go, and the class that needs this info is, for example, some nav mesh system. If your agent memory is built inside the behaviour tree, you will start to entangle your nav mesh code with the behaviour tree code. Then this can become a snowball, where you just need to get memory, and suddenly many parts of your project now has a dependency on the behaviour tree, but wait...wasn't the behaviour tree's purpose to deal with branching and acting? Now it is also a memory?
It would be like implementing a subclass Calculator.MathOperations, and put UI things there, like Calculator.MathOperations.ShowUIDialog(). Why does a maths class has UI in it? Shouldn't it be just...maths?
If you implement the blackboard separated, you can even re-use it in other projects/situations. If you implement it within the BT, you'll always have to take everything with it, even if the project doesn't need BTs, but rather implements HFSMs, etc
Is your geometry static?
? what do you mean
Wow, thank you so much for the thorough reply! I definitely understand its benefits now ๐ I'll give it a ahot
how can I make self learning agent AI in Unity?
How to make multiple AI follow different points in finite state machine?
I always roll my own Ai systems in games, I would make a character that uses vectors for movement, then you code it to keep within a certain range of your player and use rays for obstacle detection or you could add triggers to obstacles, which is something I have done in games, or even a dynamic vector flow field around the character and steer away from the obstacle using vector math. Using rigidbody and velocity for the movement will allow it to be affected by physics.
For a Finite State Machine or even a behavior tree, states/behaviors usually have to be hard coded in and are predefined and finite. I use a fuzzy pattern matching solution I developed, that runs in a Fuzzy State Machine (FuSM), it's similar to utility function, but rather than examine all the factors and then make a decision it chooses the 1st match, also all the conditions are binary.. Another thing to look into is Goal-Oriented Action Planning (GOAP) https://gamedevelopment.tutsplus.com/tutorials/goal-oriented-action-planning-for-a-smarter-ai--cms-20793
how would you make the character follow the player if there's a wall between them?
If you are trying to send an AI running through a static based environment it will not work. You need to unmark said objects as static if they are, give them a rigidbody so they react and potentially add a force based on AI hitting them.
Googling #archived-machine-learning is a great way to start.
I would get the companion to look at the player then have it move towards the player until it reaches a certain distance, making your npc characters move facing forwards makes it easy to use steering behaviors, so you make it look at the player, but then you can rotate it if you detect an obstacle. Using vectors is a great way to control movement.
Really there are so many ways you can do it, you could even make the npc follow waypoints periodically placed by the player and have it keep a certain distance away, then it will follow same path as the player.
Just depends on how you want your Ai to behave.
so i have to change the navmesh globally, i cant make it so person A doesnt avoid obstacles
hey umm anyone know a package that can generate pathfinding algorithm for a hexagon board?
like the A* project has one
but the shape is not how i want it
hey im trying to tell if an enemy ai's navagent has a path that it cant reach.
if (navAgent.pathStatus == NavMeshPathStatus.PathPartial)
{
Debug.LogWarning("invalidDestination true");
}
else
{
Debug.LogWarning("invalidDestination false");
}
``` neither of these are returning true or false even though the enemy is trying to reach my player standing on a ledge that it cant reach. the NavMesh.SamplePosition() returns true because it is a valid nav mesh position however it clearly cannot create a path to it.
ive also tried == NavMeshPathStatus.PathInvalid too which also has no results
I'm able to get it to work with flat ground
but is there not a way I can do it with windows / walls?
It would be 100x more helpful if instead of Carving out the Navmesh, it would allow you to change the mask of the ground below it.
I can probably change the ground below the windows to the layer and make the windows not static, but that's extremely finicky so it's a last resort
nono wait, i built all the buildings in a way where that shouldn't be very hard
but the table and chairs elude me
hahaaa it works
Hello guys, is there someone who work on rts game have question about navmesh Agents local avoidance.
don't ask to ask just ask
Where did NavMeshSurface go?
I can add a NavMeshSurface component in the editor, but I can't access the NavMeshSurface class in script?
What gives?
Fixed now, just Unity editor being weird I guess.
Here is my code for an SCP 173 enemy, I need to add raycasting from the player to the enemy to make the enemy stop, but I have no clue how to do this. can someone help?
https://pastebin.com/YunP9men
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.
has anyone here worked with the A* pathing project?
I have a question about the generated grid heightmap. Is there a way to make an agent stick to the heightmap generated by the grid?
i was suggested to ask here, so...
when someone gets a chance, my charicter rotates on the y axis when i move, and i am using navmesh to move, the code seems fine i was told, i think that its my navmesh or the navmesh agent that causes it when i use the set destination
I may be a little late but do you still have that problem? I have worked with A Pathfinding before.
I do. I used a weird way but I would like a better approach
Im considering writing it myself
i need a 8x8 hex grid (square layout).
cause its like a board
the weird approach was to use the point grid
and give it all my points and restrict the point length to 1
Hmm, I am not exactly sure how you wanted it to be. Let me see what it looks like on my side. In meantime, have you looked around through their website forums?
i have
i want the hexagon map to generate like this
i've looked at red blob game's gude on hexagons.
Oh okay, I am sorry I am no use in that area.
np
Do you have like any other things too or just wanna spawn hexagon maps
Just a hex map
I'm in 2d. I can't find the nav mesh surface
i dunno if navmesh exists in 2s
you will want to use other libs or create your own
so far the a* pathfinding project seems to be the best bet
Any good free behaviour tree solutions you guys can recommend?
Just out of curiosity, is anyone here working with ml-agents?
or is that for the ml channel?
in case anyone's interested i found this easy to setup implementation with a graph editor, pretty cool
It looks like its working. For now, i've barely tested it
my ai is pathfinding path that are clearly within the radius ive defined. can u help me figure out what is going wrong here?
Those red/yellow circles appear to be too wide to fit through the alley.. assuming they represent the agent radius.
no i figured it out
i was thinking there was some built in automatic avoidance system that accounted for the size of the AI. but it is just for graphical representation. unless im wrong
so then the fix was to create a custom graph for AI based on size.
thanks for answering tho. appreciated... again i might be wrong on my assumption, so if anyone knows, pls respond
@alpine glacier what are you using for pathfinding?
2d ai pathfinding project
How can I stop clipping like this? (the red cube)
add colliders to all objects and put rigidbodies on them with physics simulation activated
physics simulation?
if those objects are driven by ai/kinematic controllers, you have to avoid collisions manually via pathing on a navmesh, a custom kinematic controller or something else
im sorry i meant it just slightly clips through walls and ramps
but it still collides with it
i do use navmesh pathing
generate the navmesh with more padding to obstacles
padding? is that on the navagent section or the navmesh window
its a concept, not necessarily an option in the gui, unity navmesh realizes it by setting the agent radius
oh so basically just making the quote unquote collider bigger
yes that does makes sense ill try to do that thanks
anyone here know how to assign penalties to something like mud on the map?
A* pathfinding project
I want it to be able to move thru a node. but i want to assign a penelty, saying if you move thru this one, you move 100x slower, so unless there is a faster path choose that. How can i do this?
thank you. figured it out
Hello everyone! I'm here to ask what way is better: Machine learning or AI? I'm asking because I'm working on a project where, in assumption, an AI/ML would predict the behaviour of some chemical compounds as well how the chemical equations to use.
Well, ML is a subcategory of AI. For prediction, training an ML model based on a free forward neural network (with supervised learning) is a good method.
At least for offline learning
For online learning im not sure
I'm trying to figure out a good way to make my navigation agents surround its target properly, instead of clustering on one side. I know of the technique of having points around the target that my agents can path to and occupy, but it's not a great solution to my problem. Are there any alternatives? Doesnt have to relate to Unity's navigation system, i cant get it working in my own system either.
dont know what exactly you mean but perhaps this vid helps https://youtu.be/6BrZryMz-ac
Combat keeps the player engaged as they explore my game, so I improved how the enemy interacts with the player and their environment. This tweak made combat so fun that a tester spent over an hour repeatedly fighting a handful of enemies. At this point I knew I had an engaging combat system!
Howdy, and welcome to the 12th indie game devlog for ...
he does deal with enemies surrounding the player
wdym offline learning?z
Im not really interested in them to strafe in and out of combat. Would like them to stand in position while they attack. And if they cant reach the target, they go around the blocking agents to reach the target. But thanks for the link either way
Not sure if that is the official term, but its when the neural network model has completed its training and is deployed to the game, and the model doesnt learn while a real player is playing. this is opposite to online learning when the ML model learns as the player is playing, to learn the patterns of that specific player. (again, might not be official terminology)
so in this case I should use ML?
ML can be both offline and online. But I think offline would be easier to implement
I don thtink i understand the problem completely. You are making a system that puts two elements together to create a chemical reaction. Wouldnt the chemical reaction be the same every time? Does the AI need to predict that?
Either way I think offline is the way to go, since it doesnt seem like a player behaviour would impact your system.
I rather mean like
properties
of the product
Yeah, I'm pretty sure its a problem that a free forward neural network could solve.
as long as you have a set of training examples for it to learn on
Since I'm not the most experience in the field of neural networks, free forward neural network is...?
A free forward network is the most common artifical neural network and probably the one you'll learn about when learning about neural networks. It's a multi-layered network where data gets forwarded and adjusted from input to output. I'm still learning about it for my thesis, so i shouldnt be lecturing on it. But there's a lot of great guides online about it. This is a great guide on how neural networks work: https://www.youtube.com/playlist?list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi
and it works in unity?
ML agents in unity use deep reinforcment learning, which is sort of a mixture of this techinique and reinforcement learning. Im not too educated on it. But what I think you could do is train your model with Pytorch (which unity ML agents is based on) and then export it as .onnx file, and then put it into unity ML agents, and use it as your "inference" behaviour: https://medium.com/@a.abelhopereira/how-to-use-pytorch-models-in-unity-aa1e964d3374
Disclaimer: I have not done this, this is just research ive done for my thesis which is about this subject
Seems to be the way to go though, since supervised learning seems to be used more for prediction than reinforcement learning
Don't ML Agents only operate on numbers though?
Yeah, pretty sure all ML models do that. You could map numbers to specific properties/chemical elements
Either way, if you're sitll not sure, im sure the people at #archived-machine-learning text channel could help you.
aight, thanks
Uh, hey @thorn hemlock , I am having a bit of an issue with what you've sent me
What kind of issue?
hello,
if my navmesh agent is too far away from a baked navmesh, it sets a path towards the closest baked navmesh edge,
how can I turn off this behavior?
(Auto Repath is already off)
[edit: solved]
I used https://www.youtube.com/watch?v=c36lUUr864M to get started with Pytorch. I'm just a beginner with Pytorch like you, so I cant really help you. Judging from your error message, it looks like you need to replace the nn.functional.tanh module with torch.tanh though.
I see.
is there a way for a navmesh agent to have a different agent radius than another? The problem is an ai is too big for the bake and slightly clips through walls while the smaller ai doesnt
@iron vault You can at least with NavMeshComponents, check the pinned post.
https://youtu.be/yxKible9r2c How can i make them run more natural?
I am using the pathfinding project. i have figured out everything except how to scan a path around moving colliders (other ai and player)
How do i generate a path that avoids going thru other ai, players'... current locations
generate "around" / "avoid"
Randomly offset the start time of the animations or spawn time of the creatures so they don't sync up, also randomize the time they take to start following you after performing an attack.
If they appear floaty due to the animation, it could help to speed the animations up by a small amount.
this is what i mean. as you can see the green line from the seeker goes thru my playertank
i want it to nav around the player
the commented out line lets up update the nodes that the player sets. however this is inefficient. instead of going thru scanning and resetting the tags on the nodes for the whole grid, i just want to delete the ones from the player, and set the new ones on the area the player is at
If i set my navagent destination only to player pos the agents clumps togheter, how can i add the position around player in a circle?
I dont know if i have the solution, but i will be trying something like this in the future. Im going to write up my own method that just check is the player is x distance or less away, and stops pathfinding forward
now if you want all ai to surround the player without clumping together?'
I suppose ai will can be set as obstacles, so they navigate around each other. so when one ai comes behind the other, it tries to go around. that might lead to a circular surrounding pattern. this ofc isnt tested, and there are probably other and better ways to do this. this is just easy to make tho
once the player is fully surrounded, further ai wont be able to find a path to the player and hence their enclosure would be thin. ... idk how to make them keep clumping like COD zombies when the player entered a glitch zone
in this case, the ai doesnt treat others as obstacles, and just pushes them aside. only stopping X distance from player. but this would mean that AI behind will push the stopped ai forward. in this event, the x distance away can become "static" or have a script that makes then flee from until x distance away from player, so they push back. but then they too will get pushed back from the further buildup of waves
in this case, the push backers can be made actually static, while they are pushing back they cant be push inwards. like a force field
the best option would be to dynamically increase the stopped ais mass by the number of ai units and increase their force as well. because static rbs, going back to dynamic will lead them to firing out. which could actually be a feature, not bug.
You want to look up how to implement flocking behaviour using boids.
Thanks guys gonna take a look
I dont think obstacles gonna work if i got many many Npcs
hi, is it possible to set a NavMeshSurface to Use "Physics Colliders" but without any physics colliders that are set to triggers?
can someone link a simple ai tutorial that updates constantly and avoids box colliders
My NavMeshAgent is spiraling to it's destination for some unknown reason. It might be because of the high maximum speed I gave it, though it's strange when the idea is to get as quickly as possible from point A to B. Is there a way to keep the speed while not making the agent spiral?
Here's a preview
Is the angularSpeed too low?
I set it to 3000
Whats agent speed set to?
I usually try max angular out at 9999 or something lol
There is always the option of forcing agent to not update rotation and doing that manually yourself.
there is nothing on google ive read the entire A* documentation or the one they provided looked thru 10+ videos and none tell how to make a enviromental changing ai bot thing
This?
2d
hmm?
guys i have a problem with my game: I added model to the game from blender and i added ai (navmesh) and script that controls ai to game. I had to rotate it because (y and x rot) and my ai stoped walking.
here's my script:
May I ask a question about pathfinding on NavMesh?
I have an actor set to walk towards a destination point on the NavMesh, but every time I try to set its position with a raycast, the Destination Point has to be close to the Player, or it won't instantiate at all
This is the code I'm using, NavMesh is baked and the variables are set on the inspector
It does move towards the point when I click real close to the Player, but not when its far
using A* pathfinding, I dislike how zombies group up around corners and want them to walk around eachother so they arent going in a single-file line. Would AlternativePath solve this?
you have to update your graph with information about positions of other agents to make this work via alternate paths
ah yeah I thought AlternativePath did that itself
dynamic graphs make pathfiniding optimizations very difficult.
(speaking in general... maybe your pathfinding system does it already)
Id have 100+ units walking around too - yikes
How would I update the graph along the newly penalized path?
make bounds on the start/end points of that new path and pass that through UpdateGraph?
you could make a local avoidance behaviour based on raycasts/collisions and only use pathfinding when actual navigation is needed
you could generate a small local navmesh around areas where agents coalesce and update only that and use secondary/local pathfinding on that
what you don't want is to calculate a whole new path on each update
i'd say overall local avoidance has many solutions and whats best depends on your particular game, there are many talks on yt from all sorts of developers on how they solved the pathing details in their games
sorry still new to A* so correct me if im not understanding - I could create new smaller grids at these locations and update/scan those explicitly?
stepping back from the specific technical solutions for a moment -- there is a conceptual difference that's important to the problem you're trying to solve. There are two different things you need your units to do: pathfinding and steering.
Pathfinding: finding a route to get from point A to point B
Steering: deciding how to move at this very moment
A* is an algorithm for pathfinding, but it doesn't really tell you much about steering at all. The naรฏve version of steering is "move in a straight line directly toward the next point on the path that A* gave me," which is what you're probably doing right now.
you want your pathfinding code to run infrequently, but your steering code will run every frame
the pathfinding output is one input into the steering. Other input could include things like the positions of nearby agents, unit health, etc
here's some helpful articles: https://gamedevelopment.tutsplus.com/series/understanding-steering-behaviors--gamedev-12732
Awesome - tysm
Does anyone know how to make an agent that moves like a car? I couldn't find the guide anywhere.
Hey. I'm using navmeshagent in my 2d topdown game, and everything worked fine but suddenly SetDestination rotates the object by -90 degrees in X, which causes the sprite to go invisible and the 2d box collider to stop working. Any solution to that?
I've tried agent.updateRotation = false but it didn't help
How do I give a route a safety check? Here you can see the AI changes cover if the player gets too close- but he is running right through the player to do so
sphere cast from the cover to the AI, if the player is between it's invalid?
that seems good enough I'll try, any other suggestions please @
- spherecast giving good results ๐
Hi Guys, i'm having a difficulty here:
i'm using this part of code:
GetComponent<NavMeshAgent>().isOnNavMesh ;
which works perfectly with default setup on my agents -> type of Humanoid
but i have set other type of Agents with different parameters and if i use it, it simply never take the value of this bool,, i don't know why, and if there is a variant to write the code to get it to work
This is what happens when i set my Agent Type of another thing that Humanoid
and when i set it back to humanoid
and i am not talking about collisions, which are really not what i espected
doesn't work at all using others AgentTypeID.
hmm i fund something here
https://docs.unity3d.com/Manual/NavMesh-BuildingComponents.html
it is not included in standard unity
got it working
that's an interesting way of doing it
at least I've never see it before.. what's going on with the blue circle is that a target?
anyone know how to make ai randomly wander? i use this script but its now working https://hastepaste.com/view/XbvbZO
can anyone guide me as to where i might ask an A* pathfinding question?
Here
thanks. I am attempting to create a couple small grids, at runtime, and they seem to generate, and are added to the Pathfinder/Graphs just fine. But i notice that the AI will only walk on which ever graph they are on when everything starts.
I do make sure to use AstarPath.active.scan, but alas, i can not seem to connect the different graphs. Is this possible?
as eg: each one of these (see red x) is a very small grid.
but after all the grids are added and scanned.. something is still not right, as the path cant complete when its attempting to get nodes from other grids..
but the enemy can move aroudn their own little grid.
ahh well i guess it just dont work. mmk. gnight all.
Hello all, I am brand new to the NavMesh plugin. The following screenshot is the result of me baking the NavMesh. Will the fact its clipping through some of the floor debris on the floor model interfere with pathing? If so what is the best solution to fix? Use a flat ground?
man, for official discord, sure seems futile looking for help here. well , cheerios.
heya i have these waypoints position/show properly in my 2d project (i load them from another game from a txt file)
the "world" consists of the tilemap + edgecolliders (also loaded from that txt file)
how would i make bots use these waypoints? ๐ค
It of course depends on your definition of AI.
tbf you're using a third party plugin expecting help from the native community of unity.. try the A* help forum/server if they have it
depends what kind of AI you need ๐
if you need an AI to walk between patrol points, attack an enemy.. die.. it's incredibly easy and you could get that going after a 20 minute tutorial probably.
Hey guys, quick question, while making a boss in a 2d game, I want to use behavior trees since I want the boss to have complex mechanic and using FSM would constraint me too much I wanted to know. Is it a better idea to code everything myself (freedom in my opinion) or to use a visual scripting tool (i.e Behavior Designer, way faster). What's your opinion?
Behavior Designer is great once you understand how trees function, total time saver. You couple that with your own scripts (designer + custom nodes) you're in for great end experience with the boss mechanics.
No need to lose the freedom writing things yourself.
A hybrid approach is best (when I say hybrid I mean really, anyone who knows what they're doing will be writing their own nodes anyway) of mixing built in functionality with unique nodes that fit your needs.
Ok thanks @stone owl ! Much Appreciated!! I will look into that, I find the designer a bit expensive for now but I love the idea of combining things!
im using the a* project free version
i forgot to take something in to account. if i make my ai's dynamic grid obstacles. the path finder which starts in their center starts finding jittery paths around it's own self
the thing i was to accomplish is just pathfind around other ai
short question, what would be the best way to create a NavMesh during Runtime if you use a procedural generated map?
my current approach looks like this
https://pastebin.com/1MVm0D3U
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 think i found the problem. It seems the collectsources method can only be used on odd layermasks
Ran across an issue with our navmesh. Where I drew the red lines, any time I spawn an agent there, they seem to teleport to the corners where I placed the green dots. Also, where I drew the blue line, they don't seem to cross at all. I've tried re-baking the nav mesh several times. As far as I can tell, the floor collider isn't somehow sitting higher than the navmesh itself. Everywhere else (so far) it seems the nav mesh is working fine. We're using 2020.3.25f1 with the built in nav mesh rather than nav mesh components. I am at a loss as to why this is happening so am asking if anyone else has any ideas
Any idea why nav mesh breaks when I try to build on other parts of my terrain? (notably with the walls)
so i have problem with navMesh baking
i have terrain with tree colliders but the navMesh seems to ignore them
how can i make it so it will make the trees as obstacles
Why does he go beyond the purple mark?
Could it be the navmesh agent's deacceleration distance that allows momentum to carry beyond the target point?
I don't know, I did it according to the guide
โ
Get the FULL course here at 80% OFF!! ๐ https://unitycodemonkey.com/courseultimateoverview.php
๐ Learn how to make BETTER games FASTER by using all the Unity Tools and Features at your disposal!
๐
๐ Get my Complete Courses! โ
https://unitycodemonkey.com/courses
๐ Learn to make awesome games step-by-step from start to finish.
๐ฎ Get my Steam Gam...
Are "navmesh building components" safe to use for a full project?
I don't really have plans on updating the Unity engine because I don't really need to, but still if there's some really wonky bugs from this package I'm not aware of I don't really want to use it lol
Need Help.
Let's say i have an enemy running on a custom made Behavior Tree.
Now when it get's attacked i would like to abandon the current sequence and go to the hurt sequence.
How do i go about doing that?
In essence i want to know how to make the behavior tree react to events
Has anyone here ever implemented an influence map for an RTS game? I get the theory behind it but I dont get how to translate the actual influence map into commands for the ai
The stopping distance of my zombie agent is not working - I have been using agent.SetDestination(Player.position); but it keeps walking into the player even with stopping distance
Can anyone help?
I might try and re do the animation because it worked before that
what on earth? the agent runs past the player before running around in circles with the player in the middle? Can anyone help me fix this?
what stoping distance did you put?
2
hey, I have an interesting scenario that I'd love a hand with: I'd like my agents to avoid skirting close to walls when possible (as it looks a bit more natural), but they still need to be able to get into tight spaces when necessary. My solution has been to bake both a "tight" navmesh and a "loose" navmesh, where the tight one hugs walls and the loose one is a bit further away. I can think of a few hackier solutions from here, but the easiest & most convenient method would be if I could simply set the "tight" navmesh to have a higher cost, so agents would avoid it unless necessary. The problem is that the loose navmesh is fully inside of the tight one -- it overlaps at every point, so it's always more expensive to travel across the area where the two navmesh costs add together, no matter what the costs are set to (unless i misunderstand how overlapping costs work). that's obviously the opposite of what I want! is there any way around this? some way to "subtract" the area of the loose mesh from the tight one?
it does not stop at all
The higher the stopping distance the greater the radius the agent runs?
here's an example of my testing area: yellow is the tight navmesh, blue is the loose one (although it's really both, since they overlap)
these are both NavMeshSurfaces, by the way -- not sure if that's relevant
I made a nav mesh enemy but it seems to just immediately clip through the floor. how could i fix that? i have baked mesh data.
Do you have a NavMeshSurface on the same game object as a NavMeshAgent?
no. the navmeshagent is on a different object
How would I generate a navmesh allowing for these two to connect?
Try making the agent radius smaller or decrease voxel size in the navmeshsurface then rebake
Working on a player mining a block and making AstarPath recognized it gets removed
AstarPath.active.AddWorkItem(ctx =>
{
var gridGraph = AstarPath.active.data.gridGraph;
var node = gridGraph.GetNearest(new Vector2(xPos, yPos)).node;
node.Walkable = true;
gridGraph.CalculateConnectionsForCellAndNeighbours(node.position.x, node.position.y);
ctx.QueueFloodFill();
});
```It does make it walkable... but then it errors on calculating the connections. So error is with `CalculateConnectionsForCellAndNeighbours`
I've tried switching the arguments between the node's position and the xPos/yPos variables I have... I cannot seem to figure it out.
what's the error
ok. i made some progress.
I just changed that long CalculateConnections function's arguments to the xPos and yPos.
It works when i remove a block that is generated by the world..
but when i place a block and remove it... the connections arent properly calculated..
so i suppose my issue relies in the function where i place the block.
how do i stop my navmesh agents getting caught on the edges of the navmesh?
Ask them nicely
i will do that <3 ill write them a nice comment
I've honestly never experienced that maybe record a gif with gizmos enabled to see whats going on?
I can't seem to turn off the navmesh generation and have it generate from the prefabs, all the trees generate pretty jagged edges so things get stuck on them a bit
will do
Why does my AI clips on walls and obstacles? I already set up the colliders and stuff
Hi, I am Unity user from 4 years ago and I wanna start a healthy debate:
What is the best Unity AI course to program NPCS?
I took a few of them, maybe the most complete the Penny course, available in Unity Learn, but her way of programming is a bit confusing, so I have problems accessing from other objects to the variables of her scripts.
Any great AI course to use it as default system for npcs?
Maybe your obstacles or walls are not static, or maybe they were put on the scenario after baking it, so there is a navmesh down them
Hi, im new to ai and algorithms, is there a simple algorithm or ai to fix my enemies clutter up like this?
Hi,I created a realistic 3d Airplane controller, and now I want to use this controller and an ai script to follow a player. How can I do that? Thanks for your help!
I strongly recommend you search for MLAgents in Unity Learn
Thanks
This might point you into the right direction for solving issues like that https://en.m.wikipedia.org/wiki/Boids and https://gamedevelopment.tutsplus.com/series/understanding-steering-behaviors--gamedev-12732
Boids is an artificial life program, developed by Craig Reynolds in 1986, which simulates the flocking behaviour of birds. His paper on this topic was published in 1987 in the proceedings of the ACM SIGGRAPH conference.
The name "boid" corresponds to a shortened version of "bird-oid object", which refers to a bird-like object. "Boid" is also a ...
My ai gets stuck in terrain any help?
Thanks! ๐
How hard would it be yo make an enemy lile in dark souls
Lile when do the enemy attack guard or reposition
Pretty much as hard as it gets.
Oh no
Hello guys, has someone ever created a 2d graph with a* pathfinging via script?
I don't know how to set the 2D physics propriety in the code, I can't find any
start with a simple AI you'll be able to build on.. it's not impossible.
a lot of smoke and mirrors - you're not building a real robot with intelligence you're faking it!
I'm trying to use NavMesh, but when I import from GitHub I got this error
Someone can help me?
https://github.com/Unity-Technologies/NavMeshComponents/tree/master
i generate a random point. The Ships standing after they move and they can not reached the point. But how i can check that the point can not reach ? I do many thinks from the unity dokumentation but nothing help
For better understand a better overview. I dont kow how i can remove the Navmesh inside a terrain then my problem was easy to fix ๐
Is possible to install navmesh in Unity v2021?
I'm trying to install, but always I got an error :/
This code https://github.com/Unity-Technologi...ressTesting/Assets/Scripts/Utils/PathUtils.cs is supposed to calculate a list of waypoints based on a list of PolygonId returned by NavMeshQuery. However, it's causing an infinite loop, freezing the Editor, and forcing me to close it and restart. I've written the following code to call FindStraightPath - are there any issues with it?
I'm also using NavMeshComponents to generate the NavMesh
The infinite loop starts at the PathUtils.FindStraightPath call
If you make a empty Game and load it There , is there the Same Error?
Is it possible to force NavMeshAgent to ignore a specific NavMeshObstacle?
I'm making an ai for my game and was wondering how performance heavy the navmech is in larger scenes. I couldn't find any solid info on this so that brought me here
Hello all, I am implementing a utility AI solution for my ai fighter people in a sort of simulated fps game where AIs fight each other. I'm trying to wrap my head around how to handle their weapon actions like shooting, swapping weapons, and reloading, while also handing their movement actions, like standing, crouching, or running for cover. I want them to be able to do their weapon actions while also moving, but sometimes the movement might be dependent on which weapon action they're taking. For instance, if they are reloading, running for cover might make more sense. I'm really new to Utility Ai though so does it make sense to keep these systems separate even though they may rely heavily on each other? Or would it make more sense to put them into one set of actions?
Yep, locomotion should definitely be its own separated system
Yes that will probably be best. Thanks for the input ๐
You'll be even more convinced when you introduce more systems than attacking later on ๐
Do you have any advice for keeping these two systems synced? I want to avoid a situation where for instance the movement system decides to move the fighter forward to take a shot, but then the shooting system decides to reload. How can I ensure these systems are always on the same page?
I guess I could always throw in more considerations for my movement actions, but at some point it will start getting bogged down. Like if my "move closer" action has to check all of the considerations for the "take a shot" action, that might become redundant
You would sample available positions in the agent movement range, and add as many considerations as you need under one single action. The scoring system will prioritize based on paramaters that you will spend a lot of time tweaking, but in the end there's only one source of truth for picking the best desired position. So I don't see any conflict per say, just maybe some balancing headache
yes actually now that I look closer your graph, you do have redundant actions IMO
i.e. get closer and find cover
i just sample positions and score them, I'll pick the best whatever it means for my game/agent (the considerations) if the end position ends up being one behind cover because it scored a high priority, then so be it, the agent will now move behind cover
Oh ok so you have just one "change position" action that does all of it?
if he's comfortable being in the open (maybe he's more brave), so be it
yes, only one "move to" action
I can still imagine multiple actions where they all compute their own desired vector that you add up in the end (like you would do for Boids if that makes sense to you), but never went that far
actually in this case your agent could be stuck between 2 places and never commiting to one, lik you were afraid in the beginning so maybe not a good idea
AI is difficult... There is so much to consider lol
Like that https://en.wikipedia.org/wiki/Buridan's_ass ๐
What makes matters worse is that my maps are dynamic so it's not really a given what could be cover and what is not.
Buridan's ass is an illustration of a paradox in philosophy in the conception of free will. It refers to a hypothetical situation wherein an ass that is equally hungry and thirsty is placed precisely midway between a stack of hay and a pail of water. Since the paradox assumes the donkey will always go to whichever is closer, it dies of both hunger and thirst since it cannot make any rational decision between the hay and water.[1] A common variant of the paradox substitutes two identical piles of hay for the hay and water; the ass, unable to choose between the two, dies of hunger.