a different kind of collision problem

i have 2 physics objects

  1. object inserted into group gp
  2. object inserted into group bg

the two objects collide
what i am trying to do is duplicate the issue most are having with the two objects not colliding when in different groups

or maybe its cause one object is animated is why they collide idk [import]uid: 7911 topic_id: 17267 reply_id: 317267[/import]

never mind wasnt thinking one object pushing other and collision event two different things must have been a blonde moment [import]uid: 7911 topic_id: 17267 reply_id: 65267[/import]

… You’re lucky I haven’t been in the sun much the past few years and my hair is now light brown, otherwise those would be fighting words. [import]uid: 52491 topic_id: 17267 reply_id: 65367[/import]

jstrahan,

I tested your code really quick today and I still have to play with it to see if it will integrate into my existing code. My issue with physics objects not colliding correctly in separate groups is related with me moving my display group using transition.to().

Check out shane.lipscomb post in this older thread dicussion about collisions:
http://developer.anscamobile.com/forum/2011/09/12/my-code-doesnt-work-it-should

According to shane.lipscomb, if you modify the x or y coordinate values of your display group, it messes up the physics collision detection and I guess the collision occurs at the original x and y location and not the new location. I’ve seen this happen in my game through debugging and print statements. This really sucks because I need to move my display group towards the player.

For example, I’m making a parallax scrolling game where I have a bunch of coins stored in a group and the coins need to move towards the player. The player in my game cannot move forward or backward, but only up and down, similar to that game called JetPack Joyride. Because my player cannot move forward, I have to move the coins toward the player using transition.to().

By placing the coins in a group, the collision detection gets all messed up and it doesn’t work correctly. However, if the same coins are placed outside of a group and I move each coin individually, the physics collision detection works PERFECT. But now I’ve introduced a different issue to my game, by moving each coin individually across the screen, it causes a performance or stuttering issue with the fps. My coins have to go across the screen and once they get off the screen, then they have to reset their location back to the original location and later move across the screen again. The level is endless and the coins need to recursively keep coming towards the player at different time intervals.

Hopefully, this makes sense. Sorry for the long message.
[import]uid: 87837 topic_id: 17267 reply_id: 65551[/import]

Oh yeah! I got alot of coins moving. At least minimum 20 or more. [import]uid: 87837 topic_id: 17267 reply_id: 65553[/import]

think I can solve this when I get home in 30 [import]uid: 7911 topic_id: 17267 reply_id: 65561[/import]

jstrahan,

I think the real issue with physics objects in separate display groups not detecting collision correctly is when the display group is moving. I believe if the display group is static and not moving, the collision should work. However, when you try to move a display group like my game example with the coins, the existing collision detection gets all messed up and it doesn’t work properly.

bruceleroyjr [import]uid: 87837 topic_id: 17267 reply_id: 65565[/import]

ok heres the problem you are having and what to do

when you insert the coins in the group there x,y values are alway in the same position the groups x,y is whats changing so if your player is at 240,160 and you transition.to the other group and a coin is at 10,160 in that group so the coin is always at 10,160 to correct this try using this
http://developer.anscamobile.com/reference/index/objectlocaltocontent

[import]uid: 7911 topic_id: 17267 reply_id: 65566[/import]

i will try to work this into hitTest over the next day or two [import]uid: 7911 topic_id: 17267 reply_id: 65567[/import]

Yes, you are correct. That’s probably what is breaking the existing physics collision detection when you place physics objects in groups.

I speculated that the resolution to my problem would be to create my own collision detection logic, however, I wanted to avoid that because I thought there already existed a solution for this problem. I guess your hitTest collision code is the solution jstrahan =)

Let me know when you update your code and I’ll test it in my game to verify that the collision works when you place objects in display groups that are moving. [import]uid: 87837 topic_id: 17267 reply_id: 65569[/import]

good news its working now
still got to get the debug to work with this
[import]uid: 7911 topic_id: 17267 reply_id: 65570[/import]

you can download from dropbox [import]uid: 7911 topic_id: 17267 reply_id: 65571[/import]

debug now works also [import]uid: 7911 topic_id: 17267 reply_id: 65572[/import]

@peach
funny thing is if i had hair it would be dark brown/black so i had to go a long way just to get to that blonde moment [import]uid: 7911 topic_id: 17267 reply_id: 65595[/import]

Good news! Your latest code worked! I was able to get my coins to collide in a group which I never ever got working before. Good job jstrahan :slight_smile: [import]uid: 87837 topic_id: 17267 reply_id: 65612[/import]

Wow, this sounds awesome. I can’t wait for Jstrahan’s code to become available.

Naomi [import]uid: 67217 topic_id: 17267 reply_id: 65616[/import]