- Home /
Is RaycastHit an expensive operation vs something via JS?
For a game whose elements basically snap to discrete grids, I'm wondering if it would be overkill to use RaycastHit to figure out which grid square we are currently on. These grid squares would all be even 10x10's, and all elements are 10x10 square, so you can basically know the grid square to snap to by referencing the element's center.
RaycastHit is a Unity native function, so I wonder if it would be more efficient to use that instead of this JS approx. If not, then when would you want to use RaycastHit over a simple position calculation?
Answer by Eric5h5 · Dec 23, 2010 at 03:31 AM
A raycast is going to be much more expensive than simply rounding off a couple of numbers.
okay i was wondering if because it's native, it'd be faster than anything "scripting" via javascript
A lot of native stuff is "just" scripting anyway. There's no reason to be afraid of scripting; it's almost as fast as native code.
Your answer
Follow this Question
Related Questions
Detect Object that are hit by a ray 3 Answers
Raycasts don't go the right direction unless i'm really far away (javascript) 1 Answer
Raycast script help? 1 Answer
Switch GameObjects Tags with javascript 1 Answer
Recursive Raycast Spatial Search 0 Answers