Difference between revisions of "B2.WheelJoint"
m (Text replacement - "</source>" to "</syntaxhighlight>") |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
'''<translate>Available since</translate>:''' Gideros 2011.6<br/> | '''<translate>Available since</translate>:''' Gideros 2011.6<br/> | ||
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/b2.Joint|b2.Joint]]<br/> | '''<translate>Inherits from</translate>:''' [[Special:MyLanguage/b2.Joint|b2.Joint]]<br/> | ||
+ | |||
=== <translate>Description</translate> === | === <translate>Description</translate> === | ||
− | + | A wheel joint provides two degrees of freedom: translation along an axis fixed in bodyA and rotation in the plane. You can use a joint limit to restrict the range of motion and a joint motor to drive the rotation or to model rotational friction. This joint is designed for vehicle suspensions. | |
− | A wheel joint provides two degrees of freedom: translation along an axis fixed in bodyA and rotation in the plane. You can use a | + | |
− | joint limit to restrict the range of motion and a joint motor to drive the rotation or to model rotational friction. This joint | ||
− | is designed for vehicle suspensions. | ||
− | |||
=== <translate>Examples</translate> === | === <translate>Examples</translate> === | ||
− | '''Wheel joint''' | + | '''Wheel joint''' |
− | < | + | <syntaxhighlight lang="lua"> |
+ | --create empty box2d body for joint | ||
local ground = world:createBody({}) | local ground = world:createBody({}) | ||
ground:setPosition(350, 480) | ground:setPosition(350, 480) | ||
− | --axisx, | + | --axisx, axisy values usually between 0 and 1 |
− | --0 | + | --0 0 moves freely |
− | --0 | + | --0 1 force pulling back on y axis |
− | --1 | + | --1 0 force pulling back on x axis |
− | --1 | + | --1 1 force pulling back all diretions |
local jointDef = b2.createWheelJointDef(body, ground, 350, 200, 1, 1) | local jointDef = b2.createWheelJointDef(body, ground, 350, 200, 1, 1) | ||
− | local wheelJoint = world:createJoint(jointDef)</ | + | local wheelJoint = world:createJoint(jointDef) |
+ | </syntaxhighlight> | ||
+ | |||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
Line 39: | Line 40: | ||
[[Special:MyLanguage/b2.WheelJoint:setSpringDampingRatio|b2.WheelJoint:setSpringDampingRatio]] ''<translate>sets the spring damping ratio</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:setSpringDampingRatio(damping) sets the spring damping ratio --> | [[Special:MyLanguage/b2.WheelJoint:setSpringDampingRatio|b2.WheelJoint:setSpringDampingRatio]] ''<translate>sets the spring damping ratio</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:setSpringDampingRatio(damping) sets the spring damping ratio --> | ||
[[Special:MyLanguage/b2.WheelJoint:setSpringFrequencyHz|b2.WheelJoint:setSpringFrequencyHz]] ''<translate>sets the spring frequency in Hertz (0 = disable the spring)</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:setSpringFrequencyHz(frequency) sets the spring frequency in Hertz (0 = disable the spring) --> | [[Special:MyLanguage/b2.WheelJoint:setSpringFrequencyHz|b2.WheelJoint:setSpringFrequencyHz]] ''<translate>sets the spring frequency in Hertz (0 = disable the spring)</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:setSpringFrequencyHz(frequency) sets the spring frequency in Hertz (0 = disable the spring) --> | ||
+ | |||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== <translate>Events</translate> === | === <translate>Events</translate> === | ||
=== <translate>Constants</translate> === | === <translate>Constants</translate> === | ||
|} | |} | ||
+ | |||
+ | ---- | ||
+ | *'''[[B2.Joint]]''' | ||
+ | *'''[[LiquidFun]]''' |
Latest revision as of 14:26, 13 July 2023
Supported platforms:
Available since: Gideros 2011.6
Inherits from: b2.Joint
Description
A wheel joint provides two degrees of freedom: translation along an axis fixed in bodyA and rotation in the plane. You can use a joint limit to restrict the range of motion and a joint motor to drive the rotation or to model rotational friction. This joint is designed for vehicle suspensions.
Examples
Wheel joint
--create empty box2d body for joint
local ground = world:createBody({})
ground:setPosition(350, 480)
--axisx, axisy values usually between 0 and 1
--0 0 moves freely
--0 1 force pulling back on y axis
--1 0 force pulling back on x axis
--1 1 force pulling back all diretions
local jointDef = b2.createWheelJointDef(body, ground, 350, 200, 1, 1)
local wheelJoint = world:createJoint(jointDef)
Methodsb2.WheelJoint:enableMotor enables or disables the joint motor |
EventsConstants |