Hi, i am developing a game which include a player on the way and oncoming obstacles.I want to detect collision between coming obstacles and my player. I set physic like that
1 2 3 4 | local physics = require("physics"); physics.setDrawMode("hybrid"); physics.start(); physics.setGravity(0,0); |
object.isFixedRotation = true
Apply that to any object you don't want rotating on collision.
Alternatively make them static sensors.
Peach :)
i already did like you said as you see on the code above but it doesnt detect collision if i set gravity to zero. Maybe it does not work because dynamic bodies of obstacles goes to sleep when gravity is zero even i set isAwake=true ??
Did you try something like this?
1 2 | physics.setScale( 21 ) physics.setGravity( 0, 0 ) -- no gravity vector |
i solved it just about isSensor return nil if it's initialized only in object's own class.This is not about my code : http://developer.anscamobile.com/reference/index/bodyissensor
it is simply
1 2 3 4 5 6 7 8 9 | local function onLocalPreCollision( self, event ) local object = event.other; object.isSensor = true; print("Collision"); --Also i can set gravity to zero.. end player.preCollision = onLocalPreCollision; player:addEventListener("preCollision",heroCar); |