Hello, I am trying to make a TD game where unlike most other TD games found on Roblox, tower’s ranges are different shapes, not a complete circle around the tower
This presents an issue where I can’t just use .Magnitude to see if a tower is able to attack an enemy but have to see if the enemy is in the part
In my game, enemies are stored in a table on a server script and that table is sent to the client to render the models client side, this is in order to keep the bandwidth usage as low as possible
(The tower’s range part is on the server btw)
So how would I be able to detect if an enemy is in the tower’s range despite there being no part on the server side that represents the enemy
So the more complex the shape the higher the CPU usage will be on the Server Side?
If so how can I view the Server CPU usage whilst the game is running
Just imagine: Using .Magnitude 1 time and using tons of math.sin, math.cos to calculate really small pieces of your shape. Of course server won’t like it.
Yes, when there are not really much enemies it wont have really big influence, but in case if you spawn ~250 enemies and ~250 towers then you probably will face problems like high ping, etc.
To debug your code you can use a couple of official APIs:
The first one is extremely usefull when you want to check how much time in seconds your code takes to execute:
local t = os.clock()
-- do some code here
print(`Code take {os.clock() - t} seconds to execute!`)