Elgan Posted June 24, 2014 Share Posted June 24, 2014 like with overlap and collide. is it possible to make up a callback for immovable, so that it will only be affected with certain bodie? for example a player hitting it, doesnt push it...but it still collides into walls if he kicks it and (applys velocity) Link to comment Share on other sites More sharing options...
lewster32 Posted June 24, 2014 Share Posted June 24, 2014 I can't think of a good solid way to solve this one with Arcade physics. You want walls to not be immovable but simply have so much mass that it takes a large force (such as kicking) to move them, which to me suggests P2 physics instead. You could use processCallback to set body.immovable to false temporarily, but that will mean that all collisions will suddenly start affecting that wall for the duration, and you'd also need to start running another collision loop between that moving piece of wall and all other walls, if not doing so already. It's an awkward problem based on the fact that it doesn't make much sense in real life, and the physics systems are trying to simulate something approximating real life forces. It may be a case for you having to manually create a simple physics system for this kind of action (which isn't as daunting as you'd assume) unless anyone has a better idea of doing this in a really fool-proof way? Link to comment Share on other sites More sharing options...
Elgan Posted June 24, 2014 Author Share Posted June 24, 2014 it is a strange one.basically: dont move if you walk into it. Collides with playerwaDo move if player kicks it, cif moving, collides with walls basically immovable only to players walking. i have got round this with tile callbacks and collisions processes and hits..but its messy and im not sure it will even work if the 2 players hit it at the same or similar times, one kicking , one not. i did build this in cocos2dx-html and buuilt my own physics system which works peerfect but i cant easily transfer it as it handled all movement, players too. i could hack the game when doing immovable checks to test the entitty first, but a pain on phaserjs updates. Could be a fantastic feature to add though? its simly i shouldnt be able to push the ball without kicking it, but it should hit walls. nightmare Link to comment Share on other sites More sharing options...
lewster32 Posted June 24, 2014 Share Posted June 24, 2014 It's quite a complicated scenario with no real magic answer I'm afraid! Link to comment Share on other sites More sharing options...
j0hnskot Posted June 24, 2014 Share Posted June 24, 2014 Sorry if i didn't understand the question but you want to make walls move only if they are kicked?If yes, setting immovable=true and applying a velocity only when the player kicks it (you check that with a boolean) won't solve it? Link to comment Share on other sites More sharing options...
lewster32 Posted June 24, 2014 Share Posted June 24, 2014 You'd need to both set immovable to false and start checking for collisions between the kicked wall and other walls, then detect when it comes to a stop and set immovable back to true. It's not as straightforward as it seems at first glance. Link to comment Share on other sites More sharing options...
Recommended Posts