Unity NavMeshSurface Loading Incorrectly - unity3d

I am having trouble with the NavMeshSurface build process at runtime. I followed Unity's tutorial for using the NavMeshSurface features...
https://unity3d.com/learn/tutorials/topics/navigation/making-it-dynamic?playlist=17105
...and integrated it with my project successfully. However, when the level builds the Navmesh, it builds it 90 degrees perpindicular to my level.
Visual of Navmesh being built at runtime at 90 degree perpendicular to level. NOTE: Heightmesh is being built just fine.
The tutorial didn't show any signs of this being a problem. Currently my level is being built on the XZ axis because Navmesh surfaces won't generate on the XY plane. I have tried rotating the level 90 degrees but then nothing is created. I also have taken a screenshot of my current NavMeshSettings if that will help.
Snapshot of current NavmeshSurface settings in case I have something set incorrectly.
I'm no stranger to coding, I just haven't worked with dynamic navmesh before. So if there is something else you need feel free to ask and I can post it.

Found a solution. Generate the Navmesh so it is correct, then rotate your level to how you need it. Create the NavMeshSurface on its own gameobject as a child of your level, then attach your NavMesh data to the NavMeshSurface. You can rotate the child object to then match your level again.

Related

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.

Why does the object shake, fly and fall apart in Unity 3D and how to fix it?

I recorded the video of the problem
I am trying to build a robot simulation. It is supposed to walk using joints.
I am following the process from this article
But the model is not working as it should and I don't understand why. How can I fix it?
It could be a problem with the object/fbx. Try to remove all useless components to its children. If it doesn't works, try selecting "Freeze Position" and/or "Freeze Rotation" of all x, y and z axis in the rigidbody
The Mass on your RigidBody from the inspector that i see is 0.001.
You will need to set the masses of the actual components, like they've set it to 20 in the Article. Fix the RigidBody settings and everything should work fine in this case, without the need for any advanced physics settings changed.

how to manage the Y axis with custom prefabs in arcore

I have a strange problem in Unity (I never had it in Android).
I'm currently testing how the ARCore is working with unity, so I've run the basic demo that is delivered by Google. I didn't change even one line of code. The only difference is that I've set mu own prefab, simple cube. The problem that I have is related with the level on which the object is set. It always looks like it is set below the surface. For example if I find a surface on my chair and put the object there, than the object is set from floor, not from chair. I wonder what should I change to handle this.
The funny problem is that the same test on "clean" Android is not creating such problems.
It sounds like you have to check where the pivot point of your prefab is. I believe it has to be on the "floor" / at 0 on the Y axis.

NavMesh baking finished very quickly and does not include some objects

I am doing one of Unity's official tutorials: Survival Shooter.
Unity version: 5.3.4f1 Device: Macbook, OSX 10.11
http://unity3d.com/learn/tutorials/projects/survival-shooter/environment?playlist=17144
The problem: Baking process completes almost instantly and the floor is not highlighted by a blue mesh (where highlight should mean that navmesh is calculated for there).
Here is the screenshot of it:
Then, I checked the completed scene (which was already created by Unity Team), it showed the floor fully highlighted. I just hit the bake again without touching anything and the same problem happened. So, there must be something else as I tried the original scene file without changing anything.
What am I missing here? Is there a Unity editor setting or something like that which can break the baking process?
When baking a NavMesh for your game, a crucial thing to verify is that every object which should affect navigation is marked as a Static GameObject, or at least Static for Navigation. This setting may be found in a checkbox/dropdown at the top of the properties Inspector:
It sounds like the floor object in your scene hasn't been marked as Static, meaning it won't factor into the NavMesh baking.

Textures to Object in Unity / Vuforia

I'm trying to do some Augmented Reality in Unity using the Vuforia plugin. I've managed to get everything working (I'm using a 3d model of a car), only the position of the car relative to the marker is wrong when I come to preview it (click the 'Play button at the top and watch through the computer's camera - is 'preview' the right name for this?).
It should be sitting on the the marker in the center, but instead it's floating above the marker and off to the side by quite a bit. The positioning is definitely right in the program itself, so I'm not sure why this isn't reflected in the preview.
Also: at the moment the car is simply an untextured grey object. I realise the textures are included in a subfolder, however I can't drag the entire car's folder (including the Textures subfolder) into the ImageTarget, only the .3ds file itself. Does anyone know how to apply the original textures to the car?
Thanks so much for your help in advance!
Ben
Well, to start answering your question about the drifting away part, you've probably got a Rigidbody attached to your Car? Well, if that's the case, then Go to the Inspector where the Rigidbody is and you'll see constraints.
To avoid it floating off, you might want to check Freeze Positions for whichever direction it needs. Probably Y axis.
Now, I'm not entirely sure if you're using Vector.AddForce to move your objects, but if you are then just check if your car can move if you've put all constraints on.
If you can't then in your code trying using Object.Rigidbody.SetActive(true) when you need it to start moving, and Object.Rigidbody.SetActive(false) when its done.
On the other hand, if you aren't using Vector.AddForce() then remove Rigidbody component if you've used it.
As for the material. If you've got the material in your folder that you've downloaded then just drag and drop it into Assets. Now sometimes your car may be one solid mesh, but some times it may be multiple meshes. So which ever the case. Drag the material from your Assets onto the Hierarchy panel over your car mesh/meshes and it should turn into that color.
Hope it helps. :)