[NOT POSSIBLE]So many ways a collision does not register...

Could someone please tell me why this does not register a collision…

local physics = require("physics")  
  
Random = math.random  
  
local screenW = display.contentWidth  
local screenH = display.contentHeight  
local screenHW = screenW \*.5  
local screenHH = screenH \*.5  
  
physics.setDrawMode("hybrid")  
physics.start()  
physics.setGravity(0, 0)  
  
local function MySimulation()  
 local levelGroup = display.newGroup()   
 local player = display.newRect(levelGroup, 0, screenHH, screenW, 5)  
 physics.addBody(player, "dynamic", {isSensor=false, density=1.0, friction=1.0})  
  
 local function ballCollision(self, event)  
 print("here")  
 print(event.other.name)  
 end  
  
 local ball = display.newCircle(levelGroup, screenHW, 300, 20)  
 --ball.xReference = screenHW   
 ball.yReference = screenHH - 300  
 physics.addBody(ball, "dynamic", {isSensor=false, density=1.0, friction=1.0, radius=10})  
 ball.collision = ballCollision  
 ball:addEventListener("collision", ball)  
  
 ball.angularVelocity = 20   
end  
  
MySimulation()  

I have tried 5 or 6 different ways to get this simple movement to register a collision with complete failure… [import]uid: 21331 topic_id: 23845 reply_id: 323845[/import]

I think this is a problem to be solved with collision filtering.

The docs do say that all things collide by default but I’m not necessarily sure if that’s true:
http://developer.anscamobile.com/content/game-edition-collision-detection#Collision_categories_masking_and_groups

A good visual explanation of collision filters:
http://developer.anscamobile.com/forum/2010/10/25/collision-filters-helper-chart

So in your case, something like this:

-- Make players collide with balls, and balls collide with players  
local playerFilter = {categoryBits=1, maskBits=2}  
local ballFilter = {categoryBits=2, maskBits=1} --maskBits=3 would make balls collide with players AND other balls, and so on  
  
--Then just pass the appropriate filter when you create the bodies  
physics.addBody(ball, "dynamic", {isSensor=false, density=1.0, friction=1.0, radius=10, filter=ballFilter})  

I’d give it a shot if you haven’t already! [import]uid: 87138 topic_id: 23845 reply_id: 96009[/import]

I appreciate the attempt.

Ya, this actually is a very striped down functioning piece of test code. I took out the filters on purpose to keep it extremely simple. They do not do it. The code runs as is, give it a shot.

You are correct, without filters, all will collide.

I’m really finding massive restrictions when it comes to physics and collision detection… wasted days…

I imagine it is due to the yReference point to achieve the rotation, but that really suks… transitioning an orbit is so hard on the Corona Engine… [import]uid: 21331 topic_id: 23845 reply_id: 96017[/import]

Peach, did you give this a shot? Is this do to the simple Reference point change?

I always try to provide running code to make things easier to look at, but… [import]uid: 21331 topic_id: 23845 reply_id: 96074[/import]

After studying this I found:

Note: When a Display Object is converted into a physics object, the Physics engine assumes the reference point of the object is the center of the object. Calling object:setReferencePoint() may change the reference point from Corona’s Display Object point of view but not for the Physics engine.

I knew there were scaling issues when it came to physics, but this as well…

Another weekend down the tubes… [import]uid: 21331 topic_id: 23845 reply_id: 96083[/import]

Hey Tony,

Sorry I missed this until now - have the flu and while I’ve still been working my fever induced madness has certainly slowed me down :wink:

We are working on trying to improve some of this stuff in the near future RE physics issues.

Peach [import]uid: 52491 topic_id: 23845 reply_id: 96261[/import]

Yuk! :wink: Np. I should have checked the collision before I went as far as I did with the prototype, and was just so let down by the time I found this one… Oh well, put on back-burner until another day and move on…

Hope you shrug that flu quickly and get feeling better! [import]uid: 21331 topic_id: 23845 reply_id: 96284[/import]