Forum rules - please read before posting.

Is it possible to make a nav mesh move?


I have a part of my game where I want the player to be in an elevator that is moving down a shonky rock shaft.
I want the player to be able to move around on the platform as it is descending, and to solve puzzles that allow the platform to descend further or else trigger GAME OVER events if things are done incorrectly.

Is this possible? (the moving platform) I imagine to do so one would need to program a moving nav mesh, but having looked through the action list possibilities, I can't seem to find a way to do that.

Have I missed something? Or is it better to create this kind of event in a different way?



  • edited May 4

    i'm not sure whether it's possible to move a navmesh around, but one possibility would be to move the shaft, rather than the elevator (i.e. the elevator stays fixed in position with the player on it, and the shaft moves up around them). that might work

  • edited May 5

    This is for a 2D game?

    I would say that the complication is less to do with the NavMesh itself moving, and more the fact that you'd need to move the Player as well.

    If they're pathfinding themselves during this time, you'd need to update their own position, that of their destination, and recalculate their own active pathfinding - and that's for every frame that they're moving, which would have a performance impact.

    Moving everything but the platform is a good alternative, but if you really needed the platform itself to move I'd personally look into cheating it with an effect. That is, have the NavMesh be stationary (either at the top or bottom), and keep the Player there as well. Instead of moving them, you'd instead move the platform's sprite - as well as the Player's sprite child position - so that they only appear to be moving.

    You'd probably want to make use of a local Player object for this scene, and then attach a simple script that matches the sprite's y-position to that of the platform:

    using UnityEngine;
    public class CopyYPosition : MonoBehaviour
        public Transform playerSprite;
        public Transform platformSprite;
        public float offset;
        private void LateUpdate ()
            playerSprite.position.y = playerSprite.position.y + offset;
  • I used the method @HarryOminous outlined for one scene. Moving the world around the navmesh might be easier than finding a way to move the navmesh. Smoke and mirrors :wink:

  • K k k k kool.
    Thanks for all the input! I was coming to the same conclusion myself - about moving the world around the player - after having posted.

    Also good to know that there is a way of faking the moving platform itself (yes, for a 2d game).

    If I make any progress with this I'll post an update here.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.