i want to add a simple lift/elevator to my game. so you would have two “floors” in the game and you need to step on a platform which lifts you op to go from area 1 to area 2 which already have some baked navmeshes.
thats the idea. but i am stumbeling across a problem:
how do you bake a navmesh into a moving platform? has anybody of you did this before? i searched the whole internet but couldn’t find anyone who tried it - or maybe I am using the wrong keywords
Parts of the navmesh cannot move. When the navmesh is baked, it’s baked, and you’re not allowed to change it in play mode.
In addition, trying to move a navmesh agent up a lift with physics (like you’d usually do with a lift) will cause it to complain - a navmesh agent is NOT happy if it’s not actually on the navmesh.
I can think of one quick and dirty solution:
Put a plane where the bottom and top of the elevator is. Set these as navmesh static on whatever layer the floor around the elevator has. Bake the NavMesh with them in it
When your character starts taking the elevator, turn off the character’s navmesh agent, and move it manually or with physics.
When you’ve reached the top or bottom of the elevator, reactivate the navmesh agent.
This will essentially move your agent from one part of the mesh to another. The big downside is that your character can’t move around while the lift’s moving. If you want to be able to do that, you could just write special code for moving your character while in the lift - after all, there’s probably not any obstacles you need a navmesh for avoiding there.
If you want something like a fight on a long, moving elevator, you’re going to have to do something very different. But if you just need to have a lift, this is probably the easiest solution.
Hi @RobertOne and other developer folks!
It’s old question, and Unity finally offers Navigation Mesh Baking at Run Time !
So now You can easily create elevators.
At this point of time You can only test this awesome feature in Unity 5.5.0 BETA 11 thanks to this wonderful project this wonderful project which has a bunch of example scenes that showcase many other new stuff with Navigation.
Although I found that this feature needs to be tweaked if You want to make Your character move on horizontal platform because keeping both velocities of player and platform moving this way - is a headache for me now, because old good parenting won’t work here. Once I find a good solution I’ll post an update here.