WheelJointComponent

Create and delete WheelJoint. A connected rigid body behaves like a wheel.

# Properties

[{"index":"SyncList Joints (Sync) (ReadOnly)","0":"Set Joint information."}]

##### inherited from Component:

[{"index":"boolean Enable (Sync)","0":"Checks whether Component is activated or not."}]

[{"index":"boolean EnableInHierarchy (ReadOnly) (HideFromInspector)","0":"Displays whether this Component is Enable in the hierarchy. If Entity Enable is false regardless of Component Enable, returns false."}]

[{"index":"Entity Entity (ReadOnly)","0":"The Entity that owns this component."}]

# Methods

[{"index":"int32 AddJoint(Entity targetEntity, Vector2 localAnchorA, Vector2 localAnchorB)","0":"Add Joint. Return index on success, -1 on failure"}]

[{"index":"void DestroyJoint(int32 index)","0":"Removes the Joint whose sequence number corresponds to the index."}]

[{"index":"int32 GetJointsCount()","0":"Return the number of Joints."}]

[{"index":"void SetCollideConnected(int32 index, boolean collideConnected)","0":"Set the CollideConnected value of the Joint whose sequence number corresponds to index."}]

[{"index":"void SetLocalAnchorA(int32 index, Vector2 localAnchorA)","0":"Set the LocalAnchorA value of the Joint whose sequence number corresponds to index."}]

[{"index":"void SetLocalAnchorB(int32 index, Vector2 localAnchorB)","0":"Set the LocalAnchorB value of the Joint whose sequence number corresponds to index."}]

[{"index":"void SetMaxMotorTorque(int32 index, float maxMotorTorque)","0":"Sets the MaxMotorTorque value of the Joint whose sequence number corresponds to index."}]

[{"index":"void SetMotorEnable(int32 index, boolean enable)","0":"Set the MotorEnable value of the Joint whose sequence number corresponds to index."}]

[{"index":"void SetMotorSpeed(int32 index, float speed)","0":"Set the MotorSpeed value of the Joint whose sequence number corresponds to index."}]

##### inherited from Component:

[{"index":"boolean IsClient()","0":"Returns whether the current execution environment is a client or not."}]

[{"index":"boolean IsServer()","0":"Returns whether the current execution environment is a server or not."}]

# Examples

#### SetMotorSpeed

This is an example of moving the Entity by pressing the W and S keys on the keyboard.
    
    
    @Component
    script VehicleJointController extends Component
        @ExecSpace("ServerOnly")
        method void Accelerate()
        self.Entity.WheelJointComponent:SetMotorEnable(1, true)
        self.Entity.WheelJointComponent:SetMotorSpeed(1, -10)
        end
    
        @ExecSpace("ServerOnly")
        method void Deaccelerate()
        self.Entity.WheelJointComponent:SetMotorEnable(1, true)
        self.Entity.WheelJointComponent:SetMotorSpeed(1, 10)
        end
    
        @ExecSpace("ServerOnly")
        method void EngineOff()
        self.Entity.WheelJointComponent:SetMotorEnable(1, false)
        end
    
        @EventSender("Service", "InputService")
        handler HandleKeyDownEvent(KeyDownEvent event)
        --------------- Native Event Sender Info ----------------
        -- Sender: InputService
        -- Space: Client
        ---------------------------------------------------------
    
        -- Parameters
        local key = event.key
        ---------------------------------------------------------
        if key == KeyboardKey.R then
        	if self.Entity.DistanceJointComponent:GetJointsCount() == 0 then
        		self:Connect()
        	else
        		self:Disconnect()
        	end
        end
        end
    end
    

# SeeAlso

  * KeyboardKey
  * KeyDownEvent
  * WheelJoint
  * InputService
  * [Applying Physics to Entities ](/docs?postId=761)
  * [Using Physics](/docs?postId=757)
  * [Using Various Physics Joints](/docs?postId=760)