Thomas_Nightfire Posted August 22, 2020 Share Posted August 22, 2020 I need to check is player in certain zone, which variant is more optimized? 1. Usage of ColShape: creating ColShapes as zones and using hit/leave events 2. Timer (500 ms) which checks if player position in boundaries (zone bounds will be defined in table) It will be a lot of areas where player can be, so what way more efficient to not loose bandwidth? Link to comment
Yaaruu Posted August 22, 2020 Share Posted August 22, 2020 What kind of feature that you want to make ? I didn't get it clear. If i want to check whenever the players enter and exit maybe just use the ColShape. Link to comment
Moderators IIYAMA Posted August 22, 2020 Moderators Share Posted August 22, 2020 2 hours ago, Thomas_Nightfire said: I need to check is player in certain zone, which variant is more optimized? A combination. - hit events is for starting the timer. - The timer is used to check if everybody is inside of the colshape meets all the criteria. Like if everybody is still alive or inside of a vehicle. 2 hours ago, Thomas_Nightfire said: to not loose bandwidth? For a basic script, bandwidth is only used when a player hits or leaves a colshape. You do not have control over that, since it is always working even if you do not add eventHandlers. But keep in mind that if you use that timer to synchronize the same information over and over, sure that can be bad. 1 Link to comment
Thomas_Nightfire Posted August 22, 2020 Author Share Posted August 22, 2020 25 minutes ago, IIYAMA said: A combination. - hit events is for starting the timer. - The timer is used to check if everybody is inside of the colshape meets all the criteria. Like if everybody is still alive or inside of a vehicle. For a basic script, bandwidth is only used when a player hits or leaves a colshape. You do not have control over that, since it is always working even if you do not add eventHandlers. But keep in mind that if you use that timer to synchronize the same information over and over, sure that can be bad. I'm creating script that creates weather regions and when player enters one of them, weather will change. What your advice how to do it more optimized way (using less memory, creating less lags)? I thought creating a lot of ColShapes and working with hit/leave events is a waste of memory, no? Link to comment
Moderators IIYAMA Posted August 23, 2020 Moderators Share Posted August 23, 2020 (edited) 12 hours ago, Thomas_Nightfire said: I thought creating a lot of ColShapes and working with hit/leave events is a waste of memory, no? Should be fine. As long as you do not over do it. Note: The position X and Y can also be used for the weather. Edited August 23, 2020 by IIYAMA Link to comment
Thomas_Nightfire Posted September 15, 2020 Author Share Posted September 15, 2020 On 23/08/2020 at 12:56, IIYAMA said: Should be fine. As long as you do not over do it. Note: The position X and Y can also be used for the weather. I need to create about 500 colshapes or more... Link to comment
Moderators IIYAMA Posted September 15, 2020 Moderators Share Posted September 15, 2020 58 minutes ago, Thomas_Nightfire said: I need to create about 500 colshapes or more... In that case you can better use the X and Y position. For example working with chunks, like Minecraft does: local chunkSize = 50 function convertPositionToChunk (x, y) x = x + 3000 y = y + 3000 if x > 0 and x <= 6000 and y > 0 and y <= 6000 then return math.ceil(x / chunkSize), math.ceil(y / chunkSize) end return false -- not in a chunk = out of the map end print(convertPositionToChunk (100, 200)) Or use this to make your 500 colshapes. If you really want to know if it is an issue, then just test with a potato laptop. 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now