Physics bodies and joints = no collision detection?

This has been the biggest problem while i have been developing my game. I have a ball that rolls forward on the ground when you push a button. I am using collision detection to allow you to move forward ONLY when you are collided with the ground. This works great until you hit a joint in the ground. here is an example of my ground with the physics bodies rigged up.

as soon as the ball rolls over the joint then it decides that its not collided with the ground even though its rolling on the ground still! has anyone else come across this? is this a corona bug? i just cant think of another way to create my ground and have it with ups and downs. If it were a flat ground, it works great… any ideas? thank you [import]uid: 19620 topic_id: 6190 reply_id: 306190[/import]

You cannot have a concave(Curves inwards towards itself) surface as your shape.

Split it up into simpler shapes. No idea how to describe it other than the above. All shapes must be convex or curve outwards.

An example would be this. If you had a drawing of an L shape. you could not just draw around the L with 6 points. you will need to be more creative with creating your body shapes. So for an L shape you would create a 4 sided box for the lower part of the L the _ and a second 4 point body shape for the upper part of the L the I.

Hope that makes sense.

Cheers

Mike R [import]uid: 9950 topic_id: 6190 reply_id: 21275[/import]

It does and i understand that, if you look at my image, i am using 3 seperate objects that are slightly overlapped… [import]uid: 19620 topic_id: 6190 reply_id: 21284[/import]

Apologies. I should have seen that. What happens when you hit the joins? Does it crash or fly off or what?
Cheers

Mike R [import]uid: 9950 topic_id: 6190 reply_id: 21289[/import]

it doesn’t crash or give any errors. i have a text that displays on the screen when my ball is collided with the ground, and so its all good and after it rolls over the joint, then my text disappears, meaning that it thinks its not collided with my ground object anymore. its like the transfer from one ground object to the other is so smooth that it gets confused [import]uid: 19620 topic_id: 6190 reply_id: 21293[/import]

here is a video just to show what happens… hopefully it will make more sense:

http://www.youtube.com/watch?v=YAvBkqCq-xE [import]uid: 19620 topic_id: 6190 reply_id: 21303[/import]

Not sure how you are checking for the collisions but from viewing that video it seems that the check is only happening on the first shape. Are all of these shapes part of the same body or separate bodies?
Its a pity there does not seem to be a way of private messaging so I could give you my skype name to see if we can solve this issue.

Mike R [import]uid: 9950 topic_id: 6190 reply_id: 21305[/import]

Message deleted [import]uid: 19620 topic_id: 6190 reply_id: 21306[/import]

i think that’s 3 different bodies? therefore it makes sense the collision ends when you hit a joint because you’ve left body1.

my guess is you’re setting “collided” message when it connects and clearing the message when it disconnects. but the “collided” message from connecting with body2 is being overridden by the message being cleared when it disconnects from body1

i would do a count of the number of bodies that it has collided with and only clear the message when that is 0

[import]uid: 6645 topic_id: 6190 reply_id: 21415[/import]

I believe he has made 3 shapes for a single body as I would do. If not then that’s the problem as you have stated.

Cheers

Mike R [import]uid: 9950 topic_id: 6190 reply_id: 21417[/import]

Yea so really i have 1 giant graphical object, and i am overlaying several of these shapes to makeup the “physical” ground. I am using the Collision Began and Ended, its the only way i know how to do it, how would i code it in the manner that you two are suggesting? [import]uid: 19620 topic_id: 6190 reply_id: 21420[/import]

use the method i suggested

every time a “began” fires add 1 to the total_collisions. every time an “ended” fires, subtract 1. only when total_collisions = 0 should you set the status to blank [import]uid: 6645 topic_id: 6190 reply_id: 21427[/import]

ok thats a great thought, ill give it a go and let you guys know what happens. thanks for the help [import]uid: 19620 topic_id: 6190 reply_id: 21430[/import]

hey can either of you guys help me get the right syntax? im doing:

total_collisions = + 1 (when my collision begins)
total_collisions = -1 (when my collision has ended)

im not sure the proper way to express that though, it does not like it

i also state the variable at the beginning:

local total_collisions = 0 [import]uid: 19620 topic_id: 6190 reply_id: 21470[/import]

nevermind i figured it out, dur… yay im learning!

total_collisions = total_collisions + 1

it seems to be working great thus far, i will test some more and let you know! [import]uid: 19620 topic_id: 6190 reply_id: 21476[/import]

you were probably thinking of [lua]totalCollisions += 1[/lua] but that syntax doesnt work in Lua. [import]uid: 6645 topic_id: 6190 reply_id: 21509[/import]

cool guys seems to be working great, while i have your help just another question, i can jump my circle object into the air, this works great, but every so often ill hit my jump button and it will jump 4 times higher into the air than it should have, any ideas why this would be happening? seems pretty random i cant reproduce it whenever i want [import]uid: 19620 topic_id: 6190 reply_id: 21542[/import]

I think I’m having the same issue you where. I really need help. I tried what you did here, but it didn’t work for me. It’s definitely not my buttons because I’ve tried many different techniques to movement and got the same results with collision. When my circle/ball is pushed away by joints/physics without the use of the buttons, my jump button stops working. How did you solve this? I’ve been stuck for over a week now. Thanks

[lua]local total_collisions = 0

local function onCollision(self, event )

if ( event.phase == “began” ) then
total_collisions = total_collisions + 1
circle.canJump = true

elseif ( event.phase == “ended” ) then
total_collisions = total_collisions - 1
circle.canJump = false

end
end

circle.collision = onCollision
circle:addEventListener( “collision”, circle ) [import]uid: 46082 topic_id: 6190 reply_id: 71197[/import]

Ok, i think the issue you are having is that you are making your “circle.canJump” value change with each collision, just get rid of the canJump value… really you want to just check your total number of collisions when the jump button is pressed, so here is an example:

[lua]local total_collisions = 0

local function ballJump()
if total_collisions >= 1 then
–Make ball jump
end
end

local function onCollision(self, event )

if ( event.phase == “began” ) then
total_collisions = total_collisions + 1

elseif ( event.phase == “ended” ) then
total_collisions = total_collisions - 1

end
end

circle.collision = onCollision
circle:addEventListener( “collision”, circle )[/lua]

So just make it so that when your button is pushed it calls the “ballJump” function… then it will check the total_collisions, and if it has 1 or more, then you can have it make your character jump… hope that makes sense! [import]uid: 19620 topic_id: 6190 reply_id: 71297[/import]

I’ll give this a try when I get home. Thank you so much for replying! I found a sorta odd workaround last night where I make my ball/circle’s physics a polygon to help with collision detection. It doesn’t work too well though. Thanks again! [import]uid: 46082 topic_id: 6190 reply_id: 71300[/import]