PrismaticJointComponent

You can create and delete PrismaticJoint. Constrains a connected rigid body to move only in specific axis direction.

# 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, Vector2 localAxis)","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 LocalAnchorA value of the Joint whose sequence number corresponds to index."}]

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

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

[{"index":"void SetMaxMotorForce(int32 index, float maxMotorForce)","0":"Sets the MaxMotorForce 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."}]

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

[{"index":"void SetUseLimits(int32 index, boolean useLimits)","0":"Set the UseLimits 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

In this example, pressing the W and S keys on the keyboard changes the SetMotorSpeed value. The Entity set as TargetEntityRef increases and decreases equal to the value of UpperTranslation and LowerTranslation of the PrismaticJointComponent.

#### SetMotorSpeed
    
    
    @Component
    script KeyedVerticalMover extends Component
        @ExecSpace("ServerOnly")
        method void GoUp()
        self.Entity.PrismaticJointComponent:SetMotorSpeed(1, 3)
        end
    
        @ExecSpace("ServerOnly")
        method void GoDown()
        self.Entity.PrismaticJointComponent:SetMotorSpeed(1, -3)
        end
    
        @EventSender("Service", "InputService")
        handler HandleKeyDownEvent(KeyDownEvent event)
        --------------- Native Event Sender Info ----------------
        -- Sender: InputService
        -- Space: Client
        ---------------------------------------------------------
    
        -- Parameters
        local key = event.key
        ---------------------------------------------------------
        if key == KeyboardKey.W then
        	self:GoUp()
        elseif key == KeyboardKey.S then
        	self:GoDown()
        end
        end
    end
    

# SeeAlso

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