RESOLVED: Collision differences on Mac vs iPhone
by Craig Fortune · in iTorque 2D · 04/30/2009 (5:22 pm) · 10 replies
Bug marked resolved by Michael Perry. If bug persists in 1.2, please post a new report as per the guidelines found in the 1.2 Release Details thread.
Odd issue here that took me a lil' while to track down just what was going on. I've marked this as a bug but it could just be me being dumb.
Running my game on my Mac with the TGBGame executable I was successfully having objects collide and one of the objects is destroyed via a safedelete().
However on iPhone this collision wasn't working... it simply didn't appear to happen.
Turns out the issue was I needed to have the object as having CollisionActiveReceive equal to 1 (on the object which isn't getting deleted - that object is also the one which isn't handling the onCollision event). The other object has this anyway.
Now for my question: Why am I getting different results on Mac vs iPhone? Am I lacking appreciation of some crucial bit of logic, or is this just some sort of oversight? All answers on a postcard...
Odd issue here that took me a lil' while to track down just what was going on. I've marked this as a bug but it could just be me being dumb.
Running my game on my Mac with the TGBGame executable I was successfully having objects collide and one of the objects is destroyed via a safedelete().
However on iPhone this collision wasn't working... it simply didn't appear to happen.
Turns out the issue was I needed to have the object as having CollisionActiveReceive equal to 1 (on the object which isn't getting deleted - that object is also the one which isn't handling the onCollision event). The other object has this anyway.
Now for my question: Why am I getting different results on Mac vs iPhone? Am I lacking appreciation of some crucial bit of logic, or is this just some sort of oversight? All answers on a postcard...
#2
04/30/2009 (9:34 pm)
This is just a guess since I haven't even tried to get my game running on iTGB yet, but after reading the forums it sounds like you may need to enable physics (sorry I don't know the exact function call, but I'm sure somebody will follow-up).
#3
setUsesPhysics(true)
You need to set this on all of the objects that you will be doing collision or physics operations on.
05/01/2009 (3:41 am)
The function you need is setUsesPhysics(true)
You need to set this on all of the objects that you will be doing collision or physics operations on.
#4
When I get a chance I'll peruse the code and see what is going on.
05/01/2009 (3:47 am)
It isn't a physics thing, as I'm fixing it by simply changing the collisionactivereceive setting...When I get a chance I'll peruse the code and see what is going on.
#5
Player:
setUsesPhysics
send and receive collisions
Walls:
send collisions
On the mac the collisions and everything worked correctly. On the iphone the player could walk through walls until I added receive collisions to the walls.
05/01/2009 (5:27 am)
You don't need physics. I had the following scenario:Player:
setUsesPhysics
send and receive collisions
Walls:
send collisions
On the mac the collisions and everything worked correctly. On the iphone the player could walk through walls until I added receive collisions to the walls.
#6
05/01/2009 (5:36 am)
If I had a nickel for every time this question has been asked, I would have approximately $1.50.
#7
That's why it works on the mac and not the iPhone.
All you've done is force the wall to recieve a collision it doesn't need.
05/01/2009 (7:19 am)
You need to enable physics on all objects that send and receive collisions. That includes the walls and the players. By default on the mac build, physics are enabled for everything. On the iPhone they are disabled for everything.That's why it works on the mac and not the iPhone.
All you've done is force the wall to recieve a collision it doesn't need.
#8
setUsesPhysics seems to be everyone's answer for any inconsistency between iphone/mac. But it's not always the problem.
05/01/2009 (7:41 am)
I didn't enable physics for the walls on the iphone and it works fine after enabling the receive collisions on the walls.setUsesPhysics seems to be everyone's answer for any inconsistency between iphone/mac. But it's not always the problem.
#9
I think most people give this as the answer because what you are experiencing is caused by the physics being disabled. It's the reason the collision callbacks don't behave as you expect them to.
What setting the extra flags does is effectively cause a double check of the collisions from the object with physics to the one without.
You can verify this yourself by simply looking at which callback gets the collision message.
05/01/2009 (4:33 pm)
@BretI think most people give this as the answer because what you are experiencing is caused by the physics being disabled. It's the reason the collision callbacks don't behave as you expect them to.
What setting the extra flags does is effectively cause a double check of the collisions from the object with physics to the one without.
You can verify this yourself by simply looking at which callback gets the collision message.
#10
Please post if this issue persists in iTGB 1.2. If it does, create a new thread as per the guidelines posted in the 1.2 Release Details thread.
05/08/2009 (7:08 pm)
The answers posted here are correct. If the setUsesPhysics and collision send/receive flags are not all turned on, there will be no collision. The stock binaries for the Editor and Game on the Mac have everything turned on, but if you are using one of the optimized targets for deployment you will not see the same results.Please post if this issue persists in iTGB 1.2. If it does, create a new thread as per the guidelines posted in the 1.2 Release Details thread.
Torque Owner Bret Patterson