Agents falling from navmesh on the navmesh under it - unity3d

my game is a click to move game.In an area, I've got a navmesh walkable and under it there is another walkable part of navmesh.
My problem is that usually after I attack an enemy, sometime but not always, when I click to move my player falls on the navmesh below. I ve got the same problem on the enemies, who simply are programmed to follow the player and attack while in range, who sometime fall.
Nobody has rigidbodies attached.
Any idea of the problem? Feel free to ask ask more details.
Thanks.

Check if your navmesh is set to automatically create off mesh links: open Navigation window, click Object tab, select your terrain/ground object, make sure Generate OffMeshLinks is unchecked. If that fixes the problem, and you want auto generated off mesh links, you can try adjusting the Drop Height and Jump Distance under the Navigation->Bake tab. You can also try toggling Auto Traverse Off Mesh Links on the NavMeshAgent component.

Related

How can I add NavMesh path to pass through the door in Unity

I am trying to use NavMeshAgent to move the player around in Unity.
But the doorway is not connected in NavMesh so the player can't pass through.
is there any way to add navmesh path at the doorway so that the player can go through?
I tried to change step height and max slop but does not work...
you should use Nav Mesh dynamic
for this, you need to add Nav Mesh obstacle to your door
and make it non-static.
also make sure that you have checked the "carve" .
The agent can pass through the doorway if you open the door or move it up at run time.
Make sure your character radious is thin enough as well and also adjust height of the agent if you want to move the door up.
I solved the issue by adding Off Mesh Link to the door object like #Voidsay suggested.
After adding the Off Mesh Link, it correctly shows the path and I can pass through the door.
Just selecting the floor objects both outside and inside the door to Start and End in Off Mesh Link did the trick.

Unity adding navmesh agent but why does the navmeshagent area goes on top of the object?

I don't know why, but when I tried to give a ship a navmesh agent, when played it suddenly flipped From this Normal Ship To this Flippedship. And when I check it, it is because the area of the navmesh agent is on top of the ship like this.NavMeshAgent area for the ship. Is there anyway to change it?
PlayerUnitShipRoot <----NavMeshAgent
PlayerUnitShip <----Mesh Filter & Mesh Renderer
Create a new GameObject (PlayerUnitShipRoot).
Put your orignial model (PlayerUnitShip) under it.
Add a NavMeshAgent on PlayerUnitShipRoot.
Move and rotate PlayerUnitShip to a proper position.

How can I avoid the player from moving through walls?

The problem is that the objects that make the space station are too many over 1000 objects. So it's hard to go one by one and add a collider to it.
The player have a Rigodbody and I'm using it to detect when entering a door and collide with the door collider and then open the door/s .
I marked with red circle one part of the space station for example that don't have any collider on it. So the player can move through it.
This is the screenshot also of the player inspector settings :
From what I understood from your question is that you don't want the player to pass through the walls. So then when you import an FBX there are import options with a checkbox asking if you want to generate colliders. Just check that off and hit apply.
If you only add colliders to walls you'll still very likely hit into the wall when you stand too close. Read the doc about navmesh, it bakes walkable space and autogenerates margin for non-walkable objects. It's thorough enough.
Also check Youtube channels (there are a lot).

Climb down ladder in 2D platformer game

For my game, the player character requires to climb up and down ladders those are placed in the gameplay area.
At present, I can able to climb up for my player character to climb down at present I don't have anyway. Because platform box collider applied with platform effector, so for the climb up, effector does not create any problem but now after reaching the top, it becomes solid platform so now I can't able to move downside.
For climbing up, I have followed this tutorial: How To Make 2D Ladders In Unity - Easy Tutorial
I am looking to implement some physics so I can reach downside to the ladder after reaching top.
You need 2 boolean variables isClimbingUp and isClimbingDown which depend on pressed key and a second ray, which will check -Vector2.up direction. Then just add one more 'else if' statement for down direction.
Yes, I have managed to solve this, and the game is published in the stores.
You can check using the below link:
Humpty Trumpty's Border Wall
This is my overall physics setup for the stair:
I have applied a trigger collider to my stair object and disable player gravity scale when the player within the stair.
Then after within the trigger enter and exist, I have done this:
Physics2D.IgnoreCollision(m_CapsuleCollider, myStair.platformCollider, false);
Disable collision between player and platform colliders when the player is within the stair.
I don't think, Platform Effect 2D becomes useful to me in this process but I didn't remove this to remain in the safer side.
So you have to keep a reference of the platform object which is attached to Stair.
I hope you will get a general idea to solve this problem.

How to make FBX model climbing on a slope

Related to the image below:
The Tank is a FBX model, imported with "Generate Colliders" checked. I want to make the tank walking the slope in front of it, which is just a resize cube from Unity ediftor. I tried different approaches : I added a rigidbody to the tank (receiving a message error), I added rigidbody to the cube. Nothing works.
This is my Tank Setting Capture
Could you help me ?
You Should Uncheck the 'Is Trigger' Option for that cube, So that it'll stop Your Tank colliding in to the Cube
One option you could try is implementing NavMesh and NavMeshAgent in your tank and environment. NavMeshAgent allows you to choose how big objects the agent can ignore and how steep slope it can cross etc.
Basic NavMesh implementation can be found on the unity docs: Unity Building navmesh
Remember to set all the environment as navigation static from the navigation menu in order for agent to realize that it can climb over them etc.
Maybe a bit silly, but do you have a mesh collider added to the tank object?