on 07-05-2012 01:38 AM
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?
Solved! Go to Solution.
on 07-05-2012 11:55 AM
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.
on 07-05-2012 07:47 PM
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を一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870