Hello everyone, my circle-like object is fired from a cannon. After it falls down on the ground, then it keeps spinning forward forever. I want it to spin for a few seconds and then slow down and stop. How do you stop a circle object from spinning forever? I tried a while with the linearDamping and angularDamping, set them to some different values, but that didn’t help. Any suggestion? [import]uid: 33695 topic_id: 11866 reply_id: 311866[/import]
[lua]body.angularDampening = 0.5
– Any number greater than 0 will slow a spinning physics body over
– time so just adjust to your liking.[/lua] [import]uid: 27965 topic_id: 11866 reply_id: 43243[/import]
I used it but nothing changed. I adjusted with some values but it’s still spinning. [import]uid: 33695 topic_id: 11866 reply_id: 43244[/import]
Could you post the code you’re using for the circle object? What physical properties are you setting for your circle and where are you setting the angularDampening in your code? [import]uid: 27965 topic_id: 11866 reply_id: 43245[/import]
This is how i created my circle:
myCircle = movieclip.newAnim({ “pic1.png”, “pic2.png” }, 26, 26 )
myCircle.x = 150; myCircle.y = 195
myCircle.isVisible = true
myCircle.myName = “circle”
myCircle.linearDamping = 2
myCircle.angularDamping = 0.85
myCircle.radius = 12
physics.addBody( myCircle, “dynamic”, { density=1.0, bounce=0.1, friction=0.85, radius=myCircle.radius } )
myCircle:stopAtFrame( 1 )
Does it have anything to do with the body type (static, dynamic or kinematic) or gravity ? [import]uid: 33695 topic_id: 11866 reply_id: 43249[/import]
I think I see the problem. You can’t set physical properties for a display object until after it has be turned in to a physics body. In your posted code you are trying to set physics values for myCircle before adding a physics body to it.
[lua]myCircle = movieclip.newAnim({ “pic1.png”, “pic2.png” }, 26, 26 )
myCircle.x = 150; myCircle.y = 195
myCircle.isVisible = true
myCircle.myName = “circle”
myCircle.radius = 12
– Declare the physics body first
physics.addBody( myCircle, “dynamic”, { density=1.0, bounce=0.1, friction=0.85, radius=myCircle.radius } )
– Now you can change the physical properties
myCircle.linearDamping = 2
myCircle.angularDamping = 0.85
myCircle:stopAtFrame( 1 )[/lua] [import]uid: 27965 topic_id: 11866 reply_id: 43301[/import]
That worked !! man, thanks a lot!!! [import]uid: 33695 topic_id: 11866 reply_id: 43308[/import]
Not a problem. [import]uid: 27965 topic_id: 11866 reply_id: 43326[/import]