|
I'm making a game that, gameplay wise, is completely 2D. A plane with 3D models on it. It's set in space with inertial physics. My physics needs are pretty simple Newtonian stuff. An object with some mass value is applied a force of So my question is wether it's worth using And I am betting that Unity physics and colliders would make this easy, but I would pay extra for them in performance due to all the features I'm not actually using on these components that it is processing anyway.
(comments are locked)
|
|
The built-in physics are better-optimized than what you can do in scripting. Just moving an object in a straight line is 30% faster with a rigidbody and AddForce vs. using Translate() in FixedUpdate, and that's obviously without any collision detection code or anything else. Adding collision and other features makes the physics engine increasingly faster by comparison. Most physics features that you're not using aren't applied anyway...friction only matters if two colliders are in constant contact, so that would never be calculated in the first place. 3D polygon collision detection only applies if you're using a mesh collider, which you wouldn't be doing anyway, you'd be using sphere colliders. There's no reason not to use the built-in physics, unless you need specific behavior that those physics can't provide. Nice answer, good to hear - and I guess this settles the speculation about whether a full 2d engine like box2d would outperform unity's physics constrained to 2d.
Apr 22 '10 at 09:48 PM
duck ♦♦
So I converted my game objects to rigid bodies, and changed my manual accel/vel/pos code to use
Apr 23 '10 at 01:31 AM
Squeegy
@Squeegy: Could be, because any test I make has physics clearly winning the speed race.
Apr 23 '10 at 02:00 AM
Eric5h5
After more experimenting, I found you are 100% right. With simple
Apr 23 '10 at 08:25 PM
Squeegy
Eric, looking at your answer I was thinking that maybe it would be more efficient for me in my game to replace a CharacterController with some kind of rigidbody setup. But I'm not sure if that would behave properly. So what do you think would be the best and most efficient alternative to a CharacterController? I'm on iOS Pro, btw.
Aug 09 '12 at 03:24 PM
agamedesigner
(comments are locked)
|
|
This developer has done some comparisons of Box2D running in Cocos2D and PhysX running in Unity and found that for the same 2D test scene Box2D is roughly twice as fast as PhysX. http://flyclops.com/battle-of-the-ios-physics-engines-197#comment-114
(comments are locked)
|
|
I've often wondered about this comparison too. I've seen a lot of 2d physics games which use the 3d engine constrained to 2 dimensions, but I've never seen any performance comparisons which weigh that up against using a scripted 2d-only physics engine. I would say if your game is genuinely only 2d circle-circle collisions & responses, a roll-your-own approach could possibly perform better. This is a guess though, and would largely depend on how you implemented your 'early-out' techniques for limiting the number of distance tests (eg, by using a large 2d grid of 'bins'). If you were to also require other arbitrary 2d shapes for collision, I'd be much less confident, but like I said, I've never seen the two methods compared for performance side-by-side. I'd be very interested to see your results.
(comments are locked)
|
|
Well, performance isn't a huge issue, unless you're planning on having lots of gameObjects. So, yes, it's worth having colliders. Rigidbodies are also good, and turning off settings doesn't really effect performance, as I said before, unless you're working with large amounts of objects. In fact, you can disable all the settings and work with
Also, scripting your own physics isn't worth the time when you have the Ageia PhysX physics engine at your fingertips. 30 ships + 90 projectiles on an iPhone. Does that count as "a lot"?
Apr 22 '10 at 09:06 PM
Squeegy
(comments are locked)
|
|
This developer has done some comparisons of Box2D running in Cocos2D and PhysX running in Unity and found that for the same 2D test scene Box2D is roughly twice as fast as PhysX. http://flyclops.com/battle-of-the-ios-physics-engines-197#comment-114
(comments are locked)
|
