Stop object going through a physical item

Hi,

I have created a rope as such with rectangles and joints, I then ‘throw’ and object at it.

It seems if I throw it with too much force it simply goes through the rope as if its not there is there any reason for this, my code is below:

[lua]local ropeTop = display.newRect(0,0,10,10)
ropeTop.x = 100
ropeTop.y = 100
physics.addBody( ropeTop, “static”)

local ropeBottom = display.newRect(0,0,10,10)
ropeBottom.x = 200
ropeBottom.y = 400
physics.addBody( ropeBottom, “static”)

local rope = {}
local joint = {}
local prevLink

– Creates a rope between two points
for j = 1,18 do
rope[j] = display.newRect(0,0,5,20)
rope[j].x = ropeTop.x
rope[j].y = ropeTop.y + (j*10)

physics.addBody( rope[j], { density=.7, friction=0.3, bounce=0 } )

– damping the board motion increases the “tension”
rope[j].angularDamping = 5000
rope[j].linearDamping = 1

– create joints
if (j > 1) then
prevLink = rope[j-1]
else
prevLink = ropeTop
end
joint[j] = physics.newJoint( “weld”, prevLink, rope[j],prevLink.x, prevLink.y )

end

– join final rope to bottom
joint[#joint + 1] = physics.newJoint( “weld”, rope[#rope], ropeBottom, rope[#rope].x,rope[#rope].y)[/lua]

Also i’m finding my rope attaches to the ropeTop object but it doesn’t seem to attach to ropeBottom, can anyone see why?

Thanks [import]uid: 72726 topic_id: 14709 reply_id: 314709[/import]

You should try this

http://developer.anscamobile.com/reference/index/bodyisbullet
[import]uid: 24708 topic_id: 14709 reply_id: 54421[/import]

Hi brian

Thanks for that, my object is set up as a bullet though, so that can’t be it.

I think it may be something to do with the rope, It is on a slight angle and it seems it could be something to do with the angle it hits the rope… what would be the best joint for this kind of thing?

Each rope item is 10 x 10 and has a rotation of -20 to put it on an angle. [import]uid: 72726 topic_id: 14709 reply_id: 54429[/import]

I found increasing the density decreased likelyhood of this happening. Then again you don’t want to make your rope too dense or it won’t behave like a real rope. [import]uid: 31262 topic_id: 14709 reply_id: 54440[/import]

Hi aaron,

Yes I find exactly the same thing happens, if I increase density it is ‘less likely’ to happen, but as you say the more you increase density the less like a rope it looks.

Plus I really dont want the ‘chance’ of it happening ever, I kind of want the rope to act like a solid object, but when something hits it, it moves, it would just destroy the whole point of the game if it even had the chance of just going through as if it wasn’t there.

Any other ideas or has anyone else encountered this?

Thanks [import]uid: 72726 topic_id: 14709 reply_id: 54443[/import]

Hey there,

Take a look at this; http://blog.anscamobile.com/2011/08/solutions-to-common-physics-challenges/

It might provide some extra insight :slight_smile:

Peach [import]uid: 52491 topic_id: 14709 reply_id: 54532[/import]