Author Topic: Which would be faster?  (Read 959 times)

Extending on the title: which would be faster? Two raycasts originating from the middle of two points, towards both points, or two raycasts firing from both points toward each other? If firing a raycast from the middle is faster, why don't we use that for weapons and just do nothing if the raycast hits the firing player in the raycast? It seems awfully faster to do that, ignoring gameplay aspects (bullets going through walls if you stand right infront of them, etc). Are the speed differences negligible?

The latter, if there's a calculation necessary for finding the middle of two points. Otherwise no difference.

But one question: Why would you do the former? Is it actually happening?

It's unclear what you're trying to achive here. A raycast from a weapon never hits the shooter, and it'd be faster to use a single raycast between the two points.

The former creates two raycasts from the center outward, which is just an extra step. I'm guessing that each raycast takes a certain amount of time to process, so having two raycasts of size 2 each would probably take slightly longer than one raycast of size 4. It'd probably take a set time to check the distance first, then an extra time to create the raycast itself. Either way the latter is simpler and is the best option

"Which would be faster? Two raycasts or two raycasts?"
The answer is neither, just use one.

"Which would be faster? Two raycasts or two raycasts?"
The answer is neither, just use one.

1 raycast shot at two points? Lol..

1 raycast shot at two points? Lol..
I'm not sure what kind of raycast would need to fire at the firing player.

now I don't know a whole lot about torque but based on what I do know about raycasting, shortening the distance between the place it starts and the target would not increase the speed of anything. assuming that's even why you think it would be faster in the first place. it's very hard to tell
but either way, the difference would certainly be negligible. this question is a good example of what you call "premature optimization"
ignoring gameplay aspects (bullets going through walls if you stand right infront of them, etc).
of all the things you could ignore, that should not be one of them