FootholdComponent

Manages all the footholds in the map. Footholds interact with RigidbodyComponent.

# Properties

##### 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":"Foothold GetFoothold(int32 footholdId)","0":"Returns Foothold corresponding to a footholdId."}]

[{"index":"table GetFootholdAll()","0":"Returns all footholds on the map."}]

[{"index":"Foothold GetNearestFootholdByPoint(Vector2 point, float distance)","0":"Finds and returns the closest foothold within a certain distance from the specified point."}]

[{"index":"Foothold Raycast(Vector2 point, Vector2 direction, float distance)","0":"Fires a moving ray over a distance in the direction from the point location and then finds and returns the first foothold colliding with this ray."}]

[{"index":"table RaycastAll(Vector2 point, Vector2 direction, float distance)","0":"Fires a moving ray over a distance in the direction from the point location and then finds and returns all footholds colliding with this ray."}]

##### 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

Touching the screen randomly selects a number and matches `GetNearestFootholdByPoint`, `Raycast`, and `RaycastAll`. This example shows how to destroy the dynamic foothold detected by these three functions.
    
    
    @Component
    script DynamicFootholdDestroyer extends Component
        @ExecSpace("ServerOnly")
        method void GetNearstFootholdByPoint(Vector2 point, number distance)
        local footholdComponent = self.Entity.CurrentMap.FootholdComponent
        if footholdComponent == nil then
        	return
        end
    
        local foothold = footholdComponent:GetNearestFootholdByPoint(point, distance)
        if foothold == nil then
        	log("There is no close foothold.")
        	return
        end
    
        local entity = _EntityService:GetEntity(foothold.OwnerId)
        if entity == nil or entity.CustomFootholdComponent == nil then
        	return
        end
    
        if entity.CustomFootholdComponent.IsDynamicFoothold == false then
        	return
        end
    
        entity:Destroy()
        end
    
        @ExecSpace("ServerOnly")
        method void Raycast(Vector2 direct, number distance)
        local footholdComponent = self.Entity.CurrentMap.FootholdComponent
        if footholdComponent == nil then
        	return
        end
    
        local foothold = footholdComponent:Raycast(self.Entity.TransformComponent.Position:ToVector2(), direct:Normalize(), distance)
        if foothold == nil then
        	log("There is no close foothold.")
        	return
        end
    
        local entity = _EntityService:GetEntity(foothold.OwnerId)
        if entity == nil or entity.CustomFootholdComponent == nil then
        	return
        end
    
        if entity.CustomFootholdComponent.IsDynamicFoothold == false then
        	return
        end
    
        entity:Destroy()
        end
    
        @ExecSpace("ServerOnly")
        method void RaycastAll(Vector2 direct, number distance)
        local footholdComponent = self.Entity.CurrentMap.FootholdComponent
        if footholdComponent == nil then
        	return
        end
    
        local footholds = footholdComponent:RaycastAll(self.Entity.TransformComponent.Position:ToVector2(), direct:Normalize(), distance)
        if footholds == nil then
        	log("There is no close foothold.")
        	return
        end
    
        for i, j in ipairs(footholds) do
        	local entity = _EntityService:GetEntity(j.OwnerId)
        	if entity == nil or entity.CustomFootholdComponent == nil then
        		return
        	end
    
        	if entity.CustomFootholdComponent.IsDynamicFoothold == false then
        		return
        	end
    
        	entity:Destroy()
        end
        end
    
        @EventSender("Service", "InputService")
        handler HandleScreenTouchEvent(ScreenTouchEvent event)
        -- Parameters
        local TouchPoint = event.TouchPoint
        --------------------------------------------------------
        local rand = _UtilLogic:RandomIntegerRange(1,3)
        log(rand)
    
        if rand == 1 then
        	self:GetNearestFootholdByPoint(_UILogic:ScreenToWorldPosition(TouchPoint), 1)
        elseif rand == 2 then
        	self:Raycast(_UILogic:ScreenToWorldPosition(TouchPoint), 5)
        else
        	self:RaycastAll(_UILogic:ScreenToWorldPosition(TouchPoint), 10)
        end
        end
    end
    

# SeeAlso

  * CustomFootholdComponent
  * UILogic
  * math
  * EntityService
  * [Making a Moving Foothold](/docs?postId=579)
  * [Making Footholds](/docs?postId=71)