Unity3d Nav Mesh Agent avoiding newly created objects - unity3d

I'm creating a randomly generated terrain game where an enemy will follow after you. The terrain is built after launch through UnityScript. I am using Nav Mesh Agent for the enemies path finding but it is unable to find its way around the newly created objects. Is there a way to update the Nav Mesh after launch to accommodate the new objects? Thanks in advance!

Aside from plugging someone else's asset store product, have you looked at the NavMeshObstacle component? It's intended for dynamic obstacles for avoidance with NavMeshAgents.
And no, you cannot (nor should need to) rebuild the NavMesh at runtime.

As far as I know you cannot rebuild navmesh.
Maybe you should try with Astar pathfinding project http://arongranberg.com/astar/. It's great and used in a lot of commercial games. Free version has option to rebuild navigation graphs.
For next questions about unity3d try here.

Related

Unity NavmeshComponent (Unable to bake navmesh)

I'm pretty new to Unity and im working on a duo project with my friend. He is generating a city with L-system, with prefabs made in MagicaVoxel, and I'm trying to populate the city with pedestrians and make them walk randomly.
I have the NavMeshComponents from git, and my problem is i can't bake the navmesh on runtime because the objects (roads houses etc.) are instantiated and pieced together on runtime. All the tutorials I've seen had object before running so they could put the navmeshsurface on it, but in this case i can't. Is there a solution for this or i should try to find a different approach? Thanks for the help.
To use the navmesh baking at runtime you need to create a empty GameObject that holds a NavMeshSurface component.
Then in your script, access that component and bake it whenever you need
using Unity.AI.Navigation
void BakeAtRuntime()
{
GetComponent<NavMeshSurface>().BuildNavMesh();
}

Unity 2D: physics-based pathfinding package/library

I'm working on a small project where the goal is to defend yourself from mass enemy hordes in a 2d environment. The goal is to have the game be physics based, with enemies pushing against eachother to create a feeling of chaos.
Now I have a setup with enemies, a player and multiple obstacles all with a Rigidbody2D and 2D-colliders (mixed types, including polygon2D collider). Now I want to have the enemies chase the player. The obstacles however are polygon shaped rigidbodies, and thus are able to move.
So I want the "navigation" mesh of some sort to update on the fly, and calculate a navigation path for many entities.
Note: I don't know how many entities yet, but let's say ~100.
The things I tried to far:
Using the built-in NavMesh package from Unity. This package does not properly support the 2D configuration of Unity
Using the NavMeshPlus package. This implements a NavMeshSurface2D component to work with the 2D environment. I got this to work, but the NavMeshAgent component to steer the enemy does not use the force attribute of the rigidbody component, but rather just sets the speed or position of the transform. If someone knows how to use the NavMeshAgent or the NavMesh API in a way to get the target direction/speed via script, that would also be a solution
I tried the A* package. Which also works, but creates a very jagged line as it only can move in 8 directions (up,down,left,right and diagonals). It also cuts the corners of the obstacles, and does not take into account the size of the object (enemy) itself, so it hangs at the corners.
If anyone knows a good package/extension or the location of documentation of the NavMesh part, that would be great!
Thank you in advance.
So I got it to work and will share the solution I took:
Using the NavMeshPlus package, I created a navmesh.
Instead of using a NavMeshAgent, I configured an agent type in the navigation window with the right physical dimensions.
Next I added a script on the enemy to function as a custom NavMeshAgent.
Add a NavMeshSurface2D reference to the script (Serialized)
Using UnityEngine.AI, call NavMesh.CalculatePath(), with the AI.NavMeshQueryFilter. This has 2 components, the agent and area setters. Both of those I get from the NavMeshSurface2D reference.
Now you have the path the agent has to follow!
By the way, I'm also aware this could be done by a custom Agent inheriting the NavMeshAgent class, I'm also looking into that. Time will tell which one will have better performance.

How to create a 3d earth that users can add pinpoints on?

What is the best software to create a 3d model of the earth, in which the user can rotate and zoom in. When the tap on a location, it creates a pinpoint to mark it. How would I go about this? I am new to 3d models, so any help is greatly appreciated. I want to place this model into an iOS app (Xcode).
You are asking a lot and I think you should try doing it yourself first. If this seems hard, try searching for a tutorial.
Here is briefly what you should do and a link to a tutorial, post or thread to all of the steps:
1. Create a model of earth and apply a texture on top of it.
If you want to create your own model, I suggest you use blender, which is what I personally like the most of all 3D editing softwares currently available. Blender Guru has an awesome beginner course about blender.
If don't want to create your model all by yourself, TurboSquid has a ton of free models for you.
(Even nasa has made a 3D model of the earth!)
2. Implement a camera orbit feature
This can be hard for beginners like you and me, but luckily Emma Prats has an amazing tutorial about it!
3. Implement code to instantiate objects on top of earth
This thread should help.
If you need help on something, make sure to post it here and we (the community) will try to help!

navigation bake for prefabs this is possible?

I have a pool of objects, this object are some prefabs, but I can not find the way to do it navigation -> bake work, there is some way to apply thebake to prefabs, or plicate it at run time.
Currently the alternative I am using is to apply the bake to an object in the unity editor and move it where the new part of the pool appears, In the same position, to be able to use the navmesh.
I would like to know if the comment is possible, or if not, the last would be a good alternative, or which would be a good alternative?
I'm sorry for my bad english, I hope you can understand me
Use Unity's advanced features, which is the "NavMeshComponents", you can bake a prefab into a single navmesh and use navmesh link to connect between those prefabs.
There's a github demo about this you can check. I've used that and it works fine.
https://github.com/Unity-Technologies/NavMeshComponents

Unity 5 3d Shop menu with prefabs

Can someone tell me how to implement other player prefabs as a shop menu LIKE THIS.
I'm going to assume that every pink rectangle is a prefab.
First, you need to understand the concept of prefabs.
Second, you need to know how to instantiate a prefab in run time.
Third, you need to acces the properties for your new fresh instantiate game object so you can change the information of that prefab if you want, maybe you want some values to be 200 instead of 100, idk.
Finally, ther's no "right way" to achieve this, but I recommend you to use Unity UI and scroll rect to achieve your goal.
If you have some time to experiment there will be a good idea to check out a pooling system so you doesn't need to use so much memory at instantiate and destroying objects at runtime, you just reuse them.
Hope it helps.