applyTorque? Vent direction

I created a spinning object using a pivot joint.  I also created a wind vent to make the object spin.  The problem I’m having is when game objects hit the spinning object it slows down.   I would think the vent should cause it to pick up speed once the other objects are no longer obstructing its movement.

I increased the applyTorque which made the object spin faster but I am having the same problem.  

Also, is there a way to see which direction the vent is blowing?  

Thanks

Lori

Is your vent object a sensor and are you following this tutorial (3rd topic): http://coronalabs.com/blog/2013/02/19/more-physics-tricks-explained/ ?

Oh, and can you show some code from your app so we can examine it and comment on what might be causing the issue?  I suggest the vent-related collision code.

Yes - I am using that tutorial.   Below is my code.

I am using Composer and this first part of the code is in the TOP section where I place events.


– RETREIVE VENT FORCE VALUES


function getVentVals( angle, power )

   local xF = math.cos( (angle-90)*(math.pi/180) ) * power

   local yF = math.sin( (angle-90)*(math.pi/180) ) * power

   return xF,yF

end


– VENT COLLISION HANDLER


function ventCollide( self,event )

   local vent = event.other

   if ( event.phase == “began” and vent.isVent == true ) then

      self.xF = self.xF+vent.xF ; self.yF = self.yF+vent.yF

   elseif ( event.phase == “ended” and vent.isVent == true ) then

      self.xF = self.xF-vent.xF ; self.yF = self.yF-vent.yF

   end

end

–handles actions in both the began and ended phases of the collision


– RUNTIME FORCE APPLICATION


 function constantForce1()

    if not ( spinner1.xF == 0 and spinner1.yF == 0 ) then

       spinner1:applyForce( spinner1.xF, spinner1.yF, spinner1.x, spinner1.y )

    end

 end

This part of the code is in Scene Create:


–CONFIGURE WIND VENT


local vent1 = display.newRect( 0, 0, 80, 80 ) – THE SIZE OF THE VENT

physics.addBody(vent1, “kinematic”, { isSensor=true } )

vent1.isVisible = true

vent1.isVent = true --so that other objects are not considered vents in the collision handler 

–vent1.rotation = 180 ; 

vent1.x = 384 ; vent1.y = 484   

vent1.xF, vent1.yF = getVentVals( vent1.rotation, 90 )


–SPINNER BUMPER


bumperBody.shape = spinnerBumperShape 

myCircle1 = display.newCircle (384, 500,5)

sceneGroup:insert(myCircle1)

physics.addBody(myCircle1,“static”,{radius=5, bounce=0.5, friction =0.953})

spinner1 = display.newImage(“Images/SpinnerBumperlrg.png”, 384, 500)

sceneGroup:insert(spinner1)

physics.addBody(spinner1, {density =4, bounce=0.5, friction =0.153})

–I’ve been playing around with the items below to see if I can make it work

spinner1:applyTorque (1000)

spinner1.angularVelocity = 100

spinner1.AngularDamping=100

spinner1.AngularImpluse= 100

spinner1.collision = ventCollide

spinner1.xF =10

spinner1.yF = 10

physics.newJoint(“pivot”,myCircle1,spinner1, myCircle1.x, myCircle1.y)

This is the code of one of the objects that seems to slow down the spinner spinning by the power of the vent:

rock=display.newImage(“Images/rock”, 180, 750) 

sceneGroup:insert(rock)

physics.addBody(rock, rockBody)

rock.id = “gameRock”

rock.linearDamping = 0.3  

rock.angularDamping = 2  

rock.isBullet = true  

rock.active = true  

rock.bullet = false  

Thanks I appreciate the assistance

I think I resolved the problem.  I increased the density of the spinner so that it is quite a bit denser than the rock…

Thanks for responding and trying to help me though.

Have a great day.

Lori

Is your vent object a sensor and are you following this tutorial (3rd topic): http://coronalabs.com/blog/2013/02/19/more-physics-tricks-explained/ ?

Oh, and can you show some code from your app so we can examine it and comment on what might be causing the issue?  I suggest the vent-related collision code.

Yes - I am using that tutorial.   Below is my code.

I am using Composer and this first part of the code is in the TOP section where I place events.


– RETREIVE VENT FORCE VALUES


function getVentVals( angle, power )

   local xF = math.cos( (angle-90)*(math.pi/180) ) * power

   local yF = math.sin( (angle-90)*(math.pi/180) ) * power

   return xF,yF

end


– VENT COLLISION HANDLER


function ventCollide( self,event )

   local vent = event.other

   if ( event.phase == “began” and vent.isVent == true ) then

      self.xF = self.xF+vent.xF ; self.yF = self.yF+vent.yF

   elseif ( event.phase == “ended” and vent.isVent == true ) then

      self.xF = self.xF-vent.xF ; self.yF = self.yF-vent.yF

   end

end

–handles actions in both the began and ended phases of the collision


– RUNTIME FORCE APPLICATION


 function constantForce1()

    if not ( spinner1.xF == 0 and spinner1.yF == 0 ) then

       spinner1:applyForce( spinner1.xF, spinner1.yF, spinner1.x, spinner1.y )

    end

 end

This part of the code is in Scene Create:


–CONFIGURE WIND VENT


local vent1 = display.newRect( 0, 0, 80, 80 ) – THE SIZE OF THE VENT

physics.addBody(vent1, “kinematic”, { isSensor=true } )

vent1.isVisible = true

vent1.isVent = true --so that other objects are not considered vents in the collision handler 

–vent1.rotation = 180 ; 

vent1.x = 384 ; vent1.y = 484   

vent1.xF, vent1.yF = getVentVals( vent1.rotation, 90 )


–SPINNER BUMPER


bumperBody.shape = spinnerBumperShape 

myCircle1 = display.newCircle (384, 500,5)

sceneGroup:insert(myCircle1)

physics.addBody(myCircle1,“static”,{radius=5, bounce=0.5, friction =0.953})

spinner1 = display.newImage(“Images/SpinnerBumperlrg.png”, 384, 500)

sceneGroup:insert(spinner1)

physics.addBody(spinner1, {density =4, bounce=0.5, friction =0.153})

–I’ve been playing around with the items below to see if I can make it work

spinner1:applyTorque (1000)

spinner1.angularVelocity = 100

spinner1.AngularDamping=100

spinner1.AngularImpluse= 100

spinner1.collision = ventCollide

spinner1.xF =10

spinner1.yF = 10

physics.newJoint(“pivot”,myCircle1,spinner1, myCircle1.x, myCircle1.y)

This is the code of one of the objects that seems to slow down the spinner spinning by the power of the vent:

rock=display.newImage(“Images/rock”, 180, 750) 

sceneGroup:insert(rock)

physics.addBody(rock, rockBody)

rock.id = “gameRock”

rock.linearDamping = 0.3  

rock.angularDamping = 2  

rock.isBullet = true  

rock.active = true  

rock.bullet = false  

Thanks I appreciate the assistance

I think I resolved the problem.  I increased the density of the spinner so that it is quite a bit denser than the rock…

Thanks for responding and trying to help me though.

Have a great day.

Lori