NavMeshAgent and position when loading

Discussion and help for Easy Save 3, The Complete Save Game & Data Serializer System for the Unity Engine
Post Reply
ecenizo
Posts: 3
Joined: Mon Sep 09, 2024 1:44 pm

NavMeshAgent and position when loading

Post by ecenizo »

Hey there! Im making way more progress now with the loading system (still reworking a lot of the classes so its as consistent as possible).

My new doubt is related to the position of an object with a NavMeshAgent: When I do the ES3.Load() on the objects I want to load this particular one "spawns" on what appears to be 0,0,0 instead of the position it was before saving.

The only intertesting difference between this gameobject and the rest is that it has a NavMeshAgent. In fact, it has some behaviour to go and wait on a certain position, and when loading and teleporting to 0,0,0 it will start moving to the posistion it was supposed to be.

Is is possible that some NavMeshAgent behaviour makes these gameobject to rest position? Any advice you could give me here?

Thanks a lot!
User avatar
Joel
Moodkie Staff
Posts: 4986
Joined: Wed Nov 07, 2012 10:32 pm

Re: NavMeshAgent and position when loading

Post by Joel »

Hi there,

To my knowledge a NavMeshAgent controls the position of the object it's attached to, so trying to move it via it's Transform would be overridden by the NavMeshAgent.

I believe to teleport a NavMeshAgent you would need to use it's Warp() method. However, for specific information on the behaviour of a NavMeshAgent and how to change and restore it's position, I recommend asking on the Unity forums as they will have more information on this.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply