ID:1896014
 
Problem description:
I'm currently using a ray-like system for stuffs like basic punches and kicks (Top-down and pixelated movements). I generated a [1x1] pixel from the center of a mob (generating as many(as needed, depending on the strength input) of the same kind protruding toward a direction (or angle) as needed (it rotates as the mob changes direction). The Ray object calls a hit proc every tick to see if anything is within its bounds.


The Ray/New() seems to take up a bit of CPU usage. I'm not sure if this is normal or not. (It's currently creating a 30 pixel length ray with 1 tick life-spam). I used the proc around few times in the test, and the CPU usage for the New() shows up as this:

Self: 0.005, Total: 0.032. Real Time: 5.632. Average: 0.00 on both.

The Hit() proc which calls itself every tick when a Ray is created (with the given lifespan) took up this:

Self: 0.003, Total: 0.020, Realtime 5.621. Average: 0.00 on both


Because this'll be the proc that'll be used for every melee-related hit-detection, I'm kinda worried that numbers are showing up (I mean they're supposed to show up, but I'm not really sure what's the accepted norm could be).

Is this within the normal range? Also, do you have any advice on creating a better method of handling hurtbox for melee type of attacks?

This sounds really high for something as simple as hit detection.
In response to Ter13
Edit: I've found a new way that is significantly less harsh on the CPU and fits my needs. Thanks for the input, though!