|
Hey all, I've got a grid of objects 100 seperate objects for a 2d game on iOS. I'm using a raycast when I tap to select the objects (each object has its own box collider) My question is if it's expensive to have a box collider on the objects even though they are idle 99% of the time and do not use any type of physics, they do, however move via transform.position = newpos and end up intersecting eachother at points. Is there any kind of performance penalty associated with doing this? Again, I'm not using any sort of physics, just the collider for raycasting to hit when a player taps the screen. Thanks!
(comments are locked)
|
|
Moving colliders without rigidbodies is actually a very bad idea, performance-wise, because it forces PhysX to recalculate whatever is necessary, for static colliders. Put kinematic rigidbodies on them and you should experience as good of performance as possible. Thanks for your answer, I will give that a try but I wanted to ask first, what do you think would be faster, converting all objects to viewport space coordinates, and checking which is closest to the mouse position/touch position, or what you are suggesting and using the ray still, Thanks a tonne
Jan 31 '11 at 10:44 PM
Helkus
Not using raycasts will be faster if you have a relatively static scene. I'd have to know more about what you're doing to make a good recommendation, but raycasting is probably only a good choice if you have a camera that's moving around through the scene, or your objects have shapes that don't lend themselves well to fast shape checks, like circles and screen-aligned rectangles.
Jan 31 '11 at 11:22 PM
Jessy
it's a static 2d puzzle, 10x10 grid of objects, all currently with cube colliders, Basically I want 0 overhead from the colliders aside from when I pick the object, so are we leaning towards removing them and doing the screenspace check instead?
Jan 31 '11 at 11:41 PM
Helkus
Keep in mind the objects themselves are moving via transform.position so they are intersecting, I was worried the colliders would have an overhead due to this, even though there should be no collision of any kind behind them (the colldiers are ONLY for ray picking)
Jan 31 '11 at 11:44 PM
Helkus
Thanks for all your help, it's definately faster with the kinmatic rigid body, I'll reply with the results of my solution too, giving that a shot now
Feb 01 '11 at 01:34 AM
Helkus
(comments are locked)
|
