Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How could I create a reliable safe zone for a combat game?

Asked by 4 years ago

I am currently creating a combat game where there is a safe zone in which players can enter in order to not receive damage or cause it, but I've thought of many ways I could do this but what would be the most reliable way?

Method 1: using the touched event for parts, I plan on having a table with a list of players and either sets them to true or false with touching the event or when the touch has ended, then players could just check if the the player they intend to hurt has their value in the table set to true or false.

Problem: Touched event I have heard is a bit unreliable and sometimes doesn't detect whether players do hit or not.

I've explored other methods such as checking magnitude every 0.1 seconds and even using the region3 check, however I also heard these are quite taxing on the games performance with 20+ players and many things moving around in such a large map, could someone guide me in the right direction in which I could achieve this safe zone?

1 answer

Log in to vote
1
Answered by 4 years ago

I’ve explored other methods such as checking magnitude every 0.1 seconds and even using the region3 check, however I also heard these are quite taxing on the games performance with 20+ players and many things moving around in such a large map, [...]

Checking magnitude every tenth of a second surely might affect performances if every tenth they're running some expensive code, and I don't see Region3 have problems, and most performance issues are due to the programmer how they are programming their project, you do not need to worry about performance during the development process, just after, but only when you need to.

I like this link a lot

Here is my suggestion nonetheless:

Make a big part which is the size of your safe zone, get the position and size of the part, and delete it once you have the two informations, now create a Region3 out of the part, with the formula :

Region3.new(pos - size/2, pos + size/2)

it should be self explanatory. I like the idea about inserting the players in a table. You should do it. You can maybe also add a BoolValue named "inSafeZone" or something along those lines, parented to the player in the Players service, and set it to true when the player is in the game, and in your weapons, or whatever can receive/give damage, just check for this BoolValue and check that the Value is true


If you would like a programmatic understanding do let me know and I'll give some pseudocode to show you more or less how you can achieve this

PS accept my answer

0
Hi man, I tried messaging you on Roblox but it appears your recipient is private D: Marmalados 193 — 4y
Ad

Answer this question