So i’m trying to create 8 nasty tentacles for my monster and having a fair bit of trouble doing so. I gather box2D doesn’t do ropes very well?? I’m new to tables and loops but learning a lot fast. I’ve hacked over some code from the bridge example and got 8 arms, made up of 16 segments. The segments still like to spin around a bit and that is something I’d like to get under control. Also I would like to have each arm react to a small applyForce on a timer to make them seem a bit more life like. I can do this if I make one but I am having trouble doing it for individual ones created in my loop. Check it out. Any suggestions guys?? I’m thinking that I can also constrain the pivot rotation.
[lua] tentacle = {}
tentacleJoint = {}
tentacleCollisionFilter = { groupIndex = -2 }
playerXJoint = player.x + 25
for i = 1,8 do
for j = 1,16 do
tentacle[j] = display.newImage( “tentacle.png” )
tentacle[j].x = playerXJoint + (j*4)
tentacle[j].y = player.y + (i - 5)
tentacle[j].rotation = 100
tentacle[j].angularDamping = 1000
physics.addBody( tentacle[j], { density=3, friction=1, bounce=0.3, filter = tentacleCollisionFilter } )
if (j > 1) then
prevLink = tentacle[j - 1]
else
prevLink = player
end
nextLink = tentacle[j]
tentacleJoint[j] = physics.newJoint( “pivot”, prevLink, nextLink, playerXJoint + (j*4), player.y + (i - 5) )
end
tentacle[10]:applyForce(1, -1)
end[/lua]
At the moment that applyForce hits all the arms at once. [import]uid: 26289 topic_id: 15580 reply_id: 315580[/import]