GhostControl performance

Hi, I’m looking for some advice on using the ghost control correctly.

For my enemies’ AI I’m using ghost controls, it worked fine when I had one enemy, however as soon as I added many of them to scene (around 15), I noticed a dramatically drop in FPS. I isolated the problem to the ghost controls (without them I had steady 60 fps).
So I added a simple optimization of waiting until the player is approaching the enemy to add the ghost control to the space.
This was an improvement but still when there are 3 or more enemies activated FPS start to drop down.

What are the general recommendations on using GhostControl?
Is this expected to happen or am I doing something completely wrong?
Should I avoid them completely?

Thanks

i don’t have time right now to talk about it (i have to go to eat) but i met the same problem. When a ghost control collide with an even a bit complex shape, things start to lag.
i found a solution with a rigidbodycontrol with a correct collision group (so it collides with nothing) and the lag vanished.

For what do you need the ghost controll? collision detection aggro ranges? ect?

@bubuche said: i don't have time right now to talk about it (i have to go to eat) but i met the same problem. When a ghost control collide with an even a bit complex shape, things start to lag. i found a solution with a rigidbodycontrol with a correct collision group (so it collides with nothing) and the lag vanished.

Thanks!, I’m going to try that and report back. Probably taking the map out of the equation will improve stuff

@Empire Phoenix said: For what do you need the ghost controll? collision detection aggro ranges? ect?

It’s the field of vision of the enemy, when the player steps in, the “chase” state gets enabled.

@bubuche, I moved the ghost collisions to a second group as you said and it performance went back to normal.
Thanks for the advice!

for a vision field, except if you need very strange shape you can do it with a simple angle check : get the direction vector of the ennemy, get the vector [ennemy_eye->player] perform the angle.
Before that check the range (if the player is too far there is no need to calculate the angle).
And after that, if the player is in range and in the fov, you can do a raytest.

And if an angle check works then a dot product (or two) can also work. No reason to bother using an angle.

I see, I understand that solution and I may reimplement the whole thing at some point (maybe MonkeyBrains?).
My idea was to use “off the shelf” tools instead or reinvent the wheel, and the physics space has been very straight forward. Just throwing stuff in the simulation and letting it notify me when the player walks in front of the enemy, or any other relevant event.

I’ve just tried adding more enemies, and the ghostcons didn’t break the framerate. Although there was some perf impact apparently caused by the BetterCharacterControl’s physics, I may have to optimize the map collision shape.
But that’s another issue.