Hello, I am currently looking into performance issues with a new feature I’m adding to a game and I have stumbled upon something rather unusual and want to know if anyone else knows what is going on here.
In the game each player/npc has a script set in client mode that handles visual effects, an important thing to note is players and npcs both use the exact same script with 0 changes (npcs have them cloned from starter player scripts). In these scripts they do may things but the important one is they have a few raycasts each frame to handle effects that stick to the floor as well as the custom state machine.
The issue I seem to be running into is the raycast for npcs is taking upwards of 2 ms each frame!!! it only happens when effects are present, which doesn’t make sense as well npcs are using the same script as players.
here is a screenshot of the micro profiler (popper is the npc its just miss named)
I have looked into the code for the raycast and well it has given me 0 ideas
all that its doing is a simple floor check for the custom state machine for animations, for more context here is that raycast function
for more context of effects in this game, they are 3D part based vfx stored in a folder in workspace, they all have CanCollide, CanQuery, and CanTouch disabled any mesh parts have box CollisionFidelity as well. I’m not sure why this would interfere with only the raycasts of npcs but it somehow does.
If anyone has any ideas or questions about this feel free to let me know. If I end up finding the solution I’ll edit this post incase anyone somehow has a similar issue.