- A* version: [5.3.4]
- Unity version: [2022.3.47]
First of all, I only have a basic understanding of DOTS ECS and don’t have any in-depth knowledge.
In a previous project, I used AIPath, but after upgrading the asset version, I’m now trying to use the newly introduced FollowerEntity system in a new project.
I heard that FollowerEntity can be used even without knowledge of ECS, so I decided to give it a try.
However, I encountered an issue (which I resolved), but I’m not sure if the way I solved it is correct, so I wanted to ask.
To explain the project briefly:
It’s a 2D top-down mobile game in the vampire survivor genre.
In the scene, I have AstarPath and an RVOSimulator.
Each monster has both FollowerEntity and AIDestinationSetter components attached.
Here’s how it works:
- Player character is spawned
- Monster prefab is instantiated with various initial settings
3.aiDestinationSetter.target is set to the player (target to chase)
When using AIPath, everything worked fine.
But with FollowerEntity, I noticed that when the monster is spawned for the first time, it teleports instantly to the player’s position.
However, after that, when reused via object pooling, it behaves normally.
So I changed the initialization order like this:
1.Instantiate the prefab with FollowerEntity component disabled
2.Set aiDestinationSetter.target
3.Enable the FollowerEntity component afterwards
With this order, it works correctly.
The issue is resolved, but I’m not sure if this is the “right” way to handle it.
Is it okay to do it like this, or will it cause problems later?
Does this issue happen because FollowerEntity gets initialized before the target is set?
I also have a question about accessing FollowerEntity properties.
In the documentation for FollowerEntity, it says “Be aware of property access costs”…
In my project, each monster has a unique movement speed,
and I need to frequently access and modify movement-related values due to status effects like slow or stun.
Example 1: Applying slow status (.maxSpeed = …)
Example 2: Applying or removing stun (.canMove = …)
Currently, I access .maxSpeed every frame in Update,
and for .canMove, I update it only when a status effect starts or ends.
Will this cause a significant performance hit?
When I was using AIPath, I could handle up to around 800 monsters without issues,
but since I’m not familiar with how ECS works internally,
I’m unsure whether it’s okay to use the same approach with FollowerEntity.