General

Reply

Level 2

Level 2
JWordsworth
Posts: 16
Registered: ‎22-04-2012
Message 1 of 3 (236 Views)
Accepted Solution

Integrating Physics2D with Bullet Entities

I was hoping that somebody out there has a bit more experience with the Physics2D library than I do. I've managed to hook the physics engine in to my game and get a basic falling block in the same world space as the game entities - ie. it's drawn using the Game Director's GL matrix and so the physics object sizes are in pixel (which may or may not be a good idea, but I'll add a 'Pixel to Meters' option later.

 

Anyway, all of the examples that come in the Physics2D sample create the physics scene at the start of the simulation and do not make changes to the scene during the simulation. Frustratingly, the engine seems to store bodies as a fixed length array - and you have to manually set the numBodies variable yourself. If a body in that list is empty, then the simulation crashes (well, throws an exception which causes it to crash).

 

With this in mind, I need a sensible way to tie bullets into the Physics engine. I would like to spawn bullets every 0.5 seconds for instance and then remove them in random order (as they hit things). Obviously, removing those bodies from the array and then reindexing all of the remaining bodies seems like a crazy solution. Similarly, moving the dead bullets to Position = (-100, -100) would probably be a bad idea - as they would still be a part of the simulation (and that would be even worse I imagine when there are 20 dead bullets sitting there waiting to be revivied as new bullets when they are fired).

 

Does anyone have any suggestions for how I might develop a system where I can easily add and remove bodies from the PhysicsScene?

Please use plain text.

Re : Integrating Physics2D with Bullet Entities

I also need to remove some rigid bodies from the PhysicsScene in my game and the best way I found was (as you said) replace it by a "dummy" fixed body with 0 value as "groupFilter". When I must add a new body, I browse the scene bodies list until I find a "dummy" rigid body. This solution seems to have satifying performance on the PS Vita device even with the maximum bodies number (250).

 

I also developed by my own a simple collision detector for non-oriented boxes and spheres which uses C# dictionaries for specific trigger zone needs (including bullets management). Again, when the both systems are used in parallel on the device on each frame, I still stay at 60 FPS.

 

Please use plain text.

Level 2

Level 2
JWordsworth
Posts: 16
Registered: ‎22-04-2012
Message 3 of 3 (194 Views)

Re : Integrating Physics2D with Bullet Entities

Great to hear that somebody else has this working with 'dummy bodies'. I have calculated that our game will probably use between 100-200 bodies maximum and I'm primarily designing it for the Vita. I assume that the Physics2D engine will develop, but as everything will be calculated through a base PhysicsEntity object updating it if/when the Physics2D engine is updated shouldn't be too much trouble. Thanks for the tips, I might come back to you with another question or two if I get stuck on implementation!
Please use plain text.
This widget could not be displayed.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.

フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと PSM DevPortalを一度ログアウトし、再度ログインしてください。






Recent News