Skip to main content

<pc-collision>

The <pc-collision> tag is used to define a collision component.

Usage

Attributes

AttributeTypeDefaultDescription
axisNumber"1"Axis for cylinder/capsule shapes (0=X, 1=Y, 2=Z)
convex-hullFlag-Whether to use a convex hull for mesh collision
enabledBoolean"true"Enabled state of the component
half-extentsVector3"0.5 0.5 0.5"Half-extents for box collision as "X Y Z" values
heightNumber"2"Height for cylinder/capsule collision shapes
radiusNumber"0.5"Radius for sphere/cylinder/capsule collision shapes
typeEnum"box"Collision shape: "box" | "capsule" | "cone" | "cylinder" | "sphere"

Example

<!-- static 1x1x1 box -->
<pc-entity>
<pc-render type="box"></pc-render>
<pc-collision></pc-collision>
<pc-rigidbody></pc-rigidbody>
</pc-entity>

<!-- dynamic sphere with radius 0.5 -->
<pc-entity>
<pc-render type="sphere"></pc-render>
<pc-collision type="sphere"></pc-collision>
<pc-rigidbody type="dynamic"></pc-rigidbody>
</pc-entity>

JavaScript Interface

You can programmatically create and manipulate <pc-collision> elements using the CollisionComponentElement API.