MovementComponent

Provides movement functions for controlling RigidbodyComponent, KinematicbodyComponent, and SideviewbodyComponent, with easy adjustments for jumping power and speed.

# Properties

[{"index":"float InputSpeed (Sync)","0":"Sets the movement speed. The higher the value, the faster the speed.\- If RigidbodyComponent is true, affects horizontal speed.\- If KinematicMove is true, affects both vertical and horizontal speed.\- If KinamaticbodyComponent is true, affects both vertical and horizontal speed.\- If SideviewbodyComponent is true, affects horizontal speed."}]

[{"index":"boolean IsClimbPaused (Sync) (ReadOnly) (HideFromInspector)","0":"Checks if paused while climbing."}]

[{"index":"float JumpForce (Sync)","0":"Set the jump strength. The bigger the value is, the higher the jump."}]

##### 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":"boolean DownJump()","0":"Jump down. Returns whether the jump down is successful or not."}]

[{"index":"float GetClimbableHeight()","0":"Returns the interactive height at which a character can climb a ladder or rope.This value is proportional to the Y-axis scale of the character and is recommended to be used as the climbHeight parameter of the PlayerControllerComponent:ActionClimb method."}]

[{"index":"boolean IsFaceLeft()","0":"Returns whether an Entity is pointing to the left."}]

[{"index":"boolean Jump()","0":"Jump. Returns whether the jump is successful or not."}]

[{"index":"void MoveToDirection(Vector2 direction, float deltaTime)","0":"Moves towards the direction during the deltaTime. deltaTime only applies when on the ladder and is in units of seconds."}]

[{"index":"void SetPosition(Vector2 position)","0":"Sets an Entity's position based on local coordinates."}]

[{"index":"void SetWorldPosition(Vector2 position)","0":"Sets Entity's location to the world-based coordinates."}]

[{"index":"void Stop()","0":"Stops moving."}]

[{"index":"void UpdateClimbableOffset()","0":"Updates the relative offset to ClimbableComponent while a character climbs a ladder or rope.Used when implementing custom scripts for PlayerControllerComponent."}]

##### 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."}]

# Events

[{"index":"ChangedMovementInputEvent","0":"Occurs when the movement input changes on the MovementComponent."}]

[{"index":"ClimbPauseEvent","0":"This event is fired when riding on an object and stopping."}]

# Examples

When the player looks left, movement starts automatically. This example also shows how to adjust jump height, initiate jumping, and stop when touching a specific entity.
    
    
    @Component
    script AutoRightMover extends Component
        @ExecSpace("ClientOnly")
        method void OnUpdate(number delta)
        	if self.isFinished then
        		self.Entity.MovementComponent:Stop() -- Movement by input is also impossible
        		return
        	end
    
        	if self.isStarted == false and self.Entity.MovementComponent:IsFaceLeft() then
        		self.isStarted = true;
        	end
    
        	if self.isStarted == false then
        		return
        	end
    
        self.Entity.MovementComponent:MoveToDirection(Vector2(1,0), delta)
        end
    end
    

# SeeAlso

  * TriggerEnterEvent
  * [Entity Movement Control Using MovementComponent](/docs?postId=546)