-
Notifications
You must be signed in to change notification settings - Fork 8
Motion Sensor Component #22
Comments
Wouldn't this cause a large amount of work on the server? The motion sensor would have to constantly check each npc/player/mob to tell if they're within its range. The amount of entities to check could get ridiculously high. |
That depends on how tricky the implementation is. Players, due to their "small" amount are not much to worry about in general. For the mobs/npcs (I like to differ them usually but they are technically all just NPCs - same array), their array is limited to 200 at most, so each Motion Sensor would actually have to iterate 200 NPCs which is not much at all. Proably the best fitting hook here is GameUpdate with a frame counter, let's say we want Motion Sensors to update on every second. So better to spread the performance over more than one frame, like checking NPCs 0-50 after the first 10 frames passed, 50-100 after the next 10 frames etc. |
Would it be possible to arrange it so that these sensors could be turned off and on by a timer next to it? So that it check every time the timer send a pulse and the pulse will pass once the mobs are cleared. |
Good idea, but this would indeed cause performance trouble. |
I might be wrong but i assumed that the sensor would sense NPCs in a larger area, lets say 50x10. Would tat cause a lot of performance issues? Because with this it's possible to make sort of a "tower defense" mode. I'm really exited about this working or not. |
The size of the area to check makes pretty much no difference in matter of performance. |
If a player, npc, mob comes into range, the component sends 1, if there are no more players closeby it sends 0.
I think the Crystal Ball would be a good sprite to represent this component.
Suggested Modifiers:
1 - The component will only react on players comming closeby.
2 - The component will only react on NPCs comming closeby.
3 - The component will only react on mobs comming closeby.
The range of the sensor should be configurable. Also, since this component can take up quite some performance for the checking, a limit per player should be configuable.
Though, I'm not sure on how useful this component will be in the end. Especially because this is quite a lot of work to implement.
The text was updated successfully, but these errors were encountered: