PhysicsColliderComponent

Sets the size and offset of the physics rigid body and triggers an event when it collides with another entity. This is automatically connected to the PhysicsRigidbodyComponent of the parent entity or its own entity. If PhysicsRigidbodyComponent does not exist, it is treated as a static physics rigid body.

# Properties

[{"index":"Vector2 BoxSize (Sync)","0":"Sets the Box Collider size."}]

[{"index":"float CircleRadius (Sync)","0":"Sets the radius length of the Circle Collider."}]

[{"index":"boolean ClientOnly (ReadOnly)","0":"If true, physics operations occur in the Client, and functions and Property changes are possible in the Client space. Physics calculation results are not synchronized with other Clients. If false, function use and Property change are possible in the Server space. Physics calculation results are synchronized with other Clients."}]

[{"index":"Vector2 ColliderOffset (Sync)","0":"Sets the Collider's offset."}]

[{"index":"ColliderType ColliderType (Sync)","0":"Sets the Collider's shape."}]

[{"index":"CollisionGroup CollisionGroup (Sync)","0":"Sets up a collision group that can determine if there is a collision or not."}]

[{"index":"float Density (Sync)","0":"Sets the density value to use when UseDensity of the attached PhysicsRigidbodyComponent is true."}]

[{"index":"boolean EnableContactEvent (Sync)","0":"Set whether PhysicsContactBeginEvent and PhysicsContactEndEvent occur. If false, neither event occurs."}]

[{"index":"float Friction (Sync)","0":"Determines the coefficient of friction. Must set a value equal to or greater than 0. Valid when UseCustomPhysicalProperties is true."}]

[{"index":"boolean IsLegacy (ReadOnly)","0":"Sets whether to support the legacy system. ColliderOffset affects the Entity's SpriteRendererComponent in the previous system. The previous system is no longer supported and will be deleted at a later date."}]

[{"index":"boolean IsSensor (Sync)","0":"If true, no physical interaction will occur, but a collision event will occur."}]

[{"index":"SyncList PolygonPoints (Sync)","0":"The positions of the points that make up the polygonal colliding body. Valid when ColliderType is Polygon."}]

[{"index":"float Restitution (Sync)","0":"Determines how much bounce occurs after a collision. Must set a value equal to or greater than 0. Valid when UseCustomPhysicalProperties is true."}]

[{"index":"boolean UseCustomPhysicalProperties (Sync)","0":"Friction and Restituion values are applied to physics rigid bodies. If false, the value of the connected PhysicsRigidbodyComponent is used."}]

##### 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":"PhysicsRigidbodyComponent GetAttachedPhysicsRigidbody()","0":"Returns the connected PhysicsRigidbodyComponent."}]

[{"index":"void OnContactBegin(PhysicsContactBeginEvent beginEvent) (ScriptOverridable)","0":"Called when two physics rigid bodies begin to collide."}]

[{"index":"void OnContactEnd(PhysicsContactEndEvent endEvent) (ScriptOverridable)","0":"Called when contact ends."}]

##### 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":"PhysicsContactBeginEvent","0":"This event is raised when two physics rigid bodies begin to collide."}]

[{"index":"PhysicsContactEndEvent","0":"This event is raised when two physics rigid bodies end collision."}]

# Examples

This example shows pressing P on the keyboard changes the CollisionGroup to Monster, preventing it from colliding with other Monsters. The SleepingMode must be set to NeverSleep.
    
    
    @Component
    script MonsterFormChanger extends Component
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
        self.Entity.PhysicsRigidbodyComponent:Sleep()
        end
    
        @ExecSpace("ServerOnly")
        method void Change()
        self.Entity.SpriteRendererComponent.SpriteRUID = "000000"
        self.Entity.PhysicsColliderComponent.CollisionGroup = CollisionGroups.Monster
        end
    end
    

# SeeAlso

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