Pathfinder object spawn at location error (more close to destination)

I use Follower Entity (3D) for my objects, but there’s really no height difference in my game, just a plane. My objects appear in the correct position most of the time when they are generated, but occasionally they will deviate from the correct position and look like they are moving a large distance towards their destination.
Here’s what I’ve confirmed:

  1. if objects Spawn with CanMove turned off, they will definitely appear in the correct position. If you turn CanMove back on after they’ve spawned for a while, they also move normally.
  2. this has nothing to do with obstacles in the scene, I tried turning off all obstacles, but the situation remains the same.
  3. This has nothing to do with whether the objects overlap or not, I tried having all the objects overlap and the probability of them generating correctly and incorrectly doesn’t seem to change.
  4. i don’t seem to observe any noticeable lag or anything like that when something goes wrong.
  5. I use prefab to generate them. Use an object pool or not dosent affect this issue.

Here’s the game recording, it may look blurry, if you can’t read it just the text description on it should suffice.
In the video, the objects are supposed to spawn in the red orb, but sometimes they spawn closer to the center (which is where their destination is).

Do you mind sharing their pathfinding and possibly spawning code? With Astar disabled on these agents I’m assuming it also works fine, right? Since it works with canMove turned off… Also can you take some screenshots when they first spawn of the Debug info menu?

(And one last question to round out my many many questions already haha- what verions of Unity and Astar are you on)

Thanks for respond!!
1.
The way I generate agents can be understood as follows:

GameObject.Instantiate(prefab, parent);

I instantiate a prefab with Follow Entity component on it
2.If Astar is disabled, they spawn at the correct place.
3.
image
4.
A* Version: A* Pathfinding Project Pro 5.2.4
UnityVersion: 2022.3.50f1

Added to that, I’ve noticed lately that it doesn’t necessarily seem to be offset against the target, but it’s definitely offset by a distance

Sorry for the late response on this one! It got marked as read- must’ve left the tab open :confused:

By any chance, is there an offset on the prefab? Like if you open the prefab itself is it’s position 0,0,0?

Also sorry, I meant the Debug Info section at the bottom of the Follower Entity component. It’s a little dropdown :smiley:

thats ok <3
Do u mean this?
image
Seems not have offset on prefab


about the"Debug Info section at the bottom of the Follower Entity component",do u mean this?


The green frame is the normally generated monster, the blue one is the one with the error. I’m not sure if this will help, but thank u

I meant this section here, but I don’t think it’ll help anymore as I learn more about the issue:

If you are able to, could you upload your project so I could download it and poke around for myself?

Thank you very much!!! Here is my project.LuckyGrave.zip - Google Drive

Here is some information that I’m not sure if it’s useful for you: the game scene is called MainScene, and the prefab that is causing the error is called Monster. The code that generates the monsters is in MonsterManager.

Hm, tried to open it and the MovEffect.cs file seems to be having issues?

Sorry, this is because Chinese was used in this script (apologies again). However, the content in this script is not used anywhere, so you can leave it alone or delete it. Thank you very much ;w; !!!

1 Like

I’m having some issues getting the project to open still. Now the Utility.cs file is causing issues- what’s that file used for, is it necessary for the project to run?

Sorry for the issue, it’s necessary for the project as it provides many tools for other classes to use. Thanks again for your patience ;w;

It’s compiling now. I think I got it to spawn units too- can you tell me what the black and magenta gizmos are? It’s making it hard to see on my end. :sweat_smile:

u mean those lines? I think they are part of A* Pathfing Project’s Debug Drawing. U can turn them off by change this to “Nothing”
image
It is on Prefab “Monster” component “FollowerEntity”(FollowerEntity is part of A* Pathfinding Project)

My previous message replied to this post instead of replying to you, so I’m a bit concerned whether you saw my message. I’m replying to you here just in case. Sorry if this bothers you, and thank you again for your patience.

You’re fine :slight_smile: I am usually not available on weekends is all. Getting around to this now.

Looking into this and I’m not sure this is an Astar issue. It may be only noticed with Astar, but I think this may have more to do with your spawning code than anything. Try this: Replace your Monster Prefab with one that has default a FollowerEntity values, and don’t change any settings on FollowerEntity and see if it still spawns incorrectly? You may also want to do the same for your graph- if you reset them both to default and they still cause issues, we can continue to look into this :+1: