B2.WheelJoint: Difference between revisions
No edit summary |
m Text replacement - "</source>" to "</syntaxhighlight>" |
||
| (15 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
'''Supported platforms:''' android | <languages /> | ||
'''Available since:''' Gideros 2011.6<br/> | <!-- GIDEROSOBJ:b2.WheelJoint --> | ||
=== Description === | '''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> | ||
'''<translate>Available since</translate>:''' Gideros 2011.6<br/> | |||
A wheel joint provides two degrees of freedom: translation along an axis fixed in bodyA and rotation in the plane. You can use a | '''<translate>Inherits from</translate>:''' [[Special:MyLanguage/b2.Joint|b2.Joint]]<br/> | ||
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>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. | ||
| style="width: 50%;"| | |||
=== Methods === | === <translate>Examples</translate> === | ||
[[b2.WheelJoint:enableMotor]] | '''Wheel joint''' | ||
[[b2.WheelJoint:getJointSpeed]] | <syntaxhighlight lang="lua"> | ||
[[b2.WheelJoint:getJointTranslation]] | --create empty box2d body for joint | ||
[[b2.WheelJoint:getMaxMotorTorque]] | local ground = world:createBody({}) | ||
[[b2.WheelJoint:getMotorSpeed]] | ground:setPosition(350, 480) | ||
[[b2.WheelJoint:getSpringDampingRatio]] | |||
[[b2.WheelJoint:getSpringFrequencyHz]] | --axisx, axisy values usually between 0 and 1 | ||
[[b2.WheelJoint:isMotorEnabled]] | --0 0 moves freely | ||
[[b2.WheelJoint:setMaxMotorTorque]] | --0 1 force pulling back on y axis | ||
[[b2.WheelJoint:setMotorSpeed]] | --1 0 force pulling back on x axis | ||
[[b2.WheelJoint:setSpringDampingRatio]] | --1 1 force pulling back all diretions | ||
[[b2.WheelJoint:setSpringFrequencyHz]] | local jointDef = b2.createWheelJointDef(body, ground, 350, 200, 1, 1) | ||
| style="width: 50%;"| | local wheelJoint = world:createJoint(jointDef) | ||
=== Events === | </syntaxhighlight> | ||
=== Constants === | |||
{|- | |||
| style="width: 50%; vertical-align:top;"| | |||
=== <translate>Methods</translate> === | |||
[[Special:MyLanguage/b2.WheelJoint:enableMotor|b2.WheelJoint:enableMotor]] ''<translate>enables or disables the joint motor</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:enableMotor(flag) enables or disables the joint motor --> | |||
[[Special:MyLanguage/b2.WheelJoint:getJointSpeed|b2.WheelJoint:getJointSpeed]] ''<translate>returns the current joint translation speed in meters per second.</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:getJointSpeed() returns the current joint translation speed in meters per second. --> | |||
[[Special:MyLanguage/b2.WheelJoint:getJointTranslation|b2.WheelJoint:getJointTranslation]] ''<translate>returns the current joint translation in meters.</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:getJointTranslation() returns the current joint translation in meters. --> | |||
[[Special:MyLanguage/b2.WheelJoint:getMaxMotorTorque|b2.WheelJoint:getMaxMotorTorque]] ''<translate>returns the maximum motor torque in N*m</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:getMaxMotorTorque() returns the maximum motor torque in N*m --> | |||
[[Special:MyLanguage/b2.WheelJoint:getMotorSpeed|b2.WheelJoint:getMotorSpeed]] ''<translate>returns the motor speed in radians per second</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:getMotorSpeed() returns the motor speed in radians per second --> | |||
[[Special:MyLanguage/b2.WheelJoint:getSpringDampingRatio|b2.WheelJoint:getSpringDampingRatio]] ''<translate>returns the spring damping ratio</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:getSpringDampingRatio() returns the spring damping ratio --> | |||
[[Special:MyLanguage/b2.WheelJoint:getSpringFrequencyHz|b2.WheelJoint:getSpringFrequencyHz]] ''<translate>returns the spring frequency in Hertz</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:getSpringFrequencyHz() returns the spring frequency in Hertz --> | |||
[[Special:MyLanguage/b2.WheelJoint:isMotorEnabled|b2.WheelJoint:isMotorEnabled]] ''<translate>is the joint motor enabled?</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:isMotorEnabled() is the joint motor enabled? --> | |||
[[Special:MyLanguage/b2.WheelJoint:setMaxMotorTorque|b2.WheelJoint:setMaxMotorTorque]] ''<translate>sets the maximum motor torque in N*m</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:setMaxMotorTorque(torque) sets the maximum motor torque in N*m --> | |||
[[Special:MyLanguage/b2.WheelJoint:setMotorSpeed|b2.WheelJoint:setMotorSpeed]] ''<translate>sets the motor speed in radians per second</translate>''<br/><!-- GIDEROSMTD:b2.WheelJoint:setMotorSpeed(speed) sets the motor speed in radians per second --> | |||
[[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) --> | |||
| style="width: 50%; vertical-align:top;"| | |||
=== <translate>Events</translate> === | |||
=== <translate>Constants</translate> === | |||
|} | |} | ||
---- | |||
*'''[[B2.Joint]]''' | |||
*'''[[LiquidFun]]''' | |||
Latest revision as of 13: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 |