Tentacles. Problems with "pivot" joints

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
        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

Ok, I have made quite a bit of progress. The only thing that is holding me back now is the elasticity of the arms/tentacles.

They are too stretchy. So when the monster moves, it's arms stretch half way across the screen before catching up.

Does anyone know a way to make the joints 'weld' better; or make the arms less stretchy.

Much Appreciated

Here is my new code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
tentacle = {}
        longTentacle = {}
        sucker = {}
        suckerJoint = {}
        tentacleJoint = {}
        longTentacleJoint = {}
        tentacleCollisionFilter = { groupIndex = -2 }
        
        playerX = player.x + 20
        playerXJoint = player.x + 17
        
        
 
        
        for i = 1,8 do
                
                for j = 1,16 do
                
                        tentacle[j] = display.newImage( "tentacle.png" )
                        tentacle[j].x = playerX + (j*4)
                        tentacle[j].y = player.y + (i - 7)
                        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 - 7) )
                        tentacleJoint[j].isLimitEnabled = true 
                        tentacleJoint[j]:setRotationLimits( -10, 10 )
                end
                
        
                tentacle[4]:applyForce(1,1)
                tentacle[8]:applyForce(-1,-1)
                
        end
        
        
        for i = 1,2 do
                
                for h = 1,25 do
                
                        longTentacle[h] = display.newImage( "tentacle.png" )
                        longTentacle[h].x =     playerX + (h*4)
                        longTentacle[h].y = player.y + (i - 7)
                        longTentacle[h].rotation = 100
                        longTentacle[h].angularDamping = 1000
                        
                        physics.addBody( longTentacle[h], { density=3, friction=1, bounce=0.3, filter = tentacleCollisionFilter } )
                
                        if (h > 1) then
                                prevLink = longTentacle[h - 1]
                        else
                                prevLink = player
                        end
                        
                        
                        nextLink = longTentacle[h]
                        
                        
                        longTentacleJoint[h] = physics.newJoint( "pivot", prevLink, nextLink, playerXJoint + (h*4), player.y + (i - 7) )
                        longTentacleJoint[h].isLimitEnabled = true 
                        longTentacleJoint[h]:setRotationLimits( -10, 10 )
                end
                
                        suckerJointX = player.x
                        suckerJointY = player.y - 5
        
                for s = 1,2 do
        
                        sucker[s] = display.newImage( "sucker.png")
                        sucker[s].x =   suckerJointX + 125
                        sucker[s].y = suckerJointY
                        --sucker[s].rotation = 100
                        sucker[s].angularDamping = 1000
                        
                        physics.addBody( sucker[s], { density=3, friction=1, bounce=0.3, filter = tentacleCollisionFilter } )
        
        
                        suckerJoint[s] = physics.newJoint( "pivot", longTentacle[25], sucker[s], suckerJointX + 122, suckerJointY )
                        suckerJoint[s].isLimitEnabled = true 
                        suckerJoint[s]:setRotationLimits( -10, 10 )
                end
        
                
        
                longTentacle[4]:applyForce(1,1)
                longTentacle[8]:applyForce(-1,0)
                
                
                
        end
views:1430 update:2011/10/15 21:01:16
corona forums © 2003-2011