Hello everyone, I have a village in my game. I want the player to be able to move around the village without pushing the houses and people around when bumps into them. Here is some code for how I created an elder and his house and the player. As it is right now. The player completely passes through the elder. When the player bumps into the house it is detected but the player can move the house around by moving into it. I don’t know if it has anything to do with it but the player is an animated sprite. If more code is needed please let me know.
[code]
local elderHouse = display.newImage(“gumm_house_smooth.png”)
elderHouse.name = “elderHouse”
elderHouse:scale(0.45, 0.45)
elderHouse:setReferencePoint(display.CenterReferencePoint)
elderHouse.x = display.contentWidth * 0.5 + 25
elderHouse.y = display.contentHeight * 0.25 - 55
physics.addBody(elderHouse, “dynamic”, {density=1.0, friction=0.5, bounce=0.0, radius= 15})
local elder = display.newImage(“gumm_elder_40X40_2.png”)
elder.name = “elder”
elder:scale(0.35, 0.35)
elder:setReferencePoint(display.CenterReferencePoint)
elder.x = display.contentWidth * 0.5 - 35
elder.y = display.contentHeight * 0.25 - 25
physics.addBody(elder, “static”, {density=0.0, friction=0.0, bounce=0.0, radius= 15})
elder.isSensor = false
local function spawnPlayer( event )
gummMoving = newGummMovingSprite()
gummMoving.name = “gummMoving”
physics.addBody(gummMoving, “dynamic”, {density=1.0, friction=0.5, bounce=0.0, radius= 10})
gummMoving.isSensor = false
gummMoving.collision = onCollision
gummMoving:addEventListener(“collision”, gummMoving)
Runtime:addEventListener(“touch”, movePlayer)
gummMoving:play()
end [import]uid: 49863 topic_id: 28391 reply_id: 328391[/import]