Aego Русский

Circle Collider 2D

Circle shape. Needs a uniform node scale.

component physics.CircleCollider2D
On this page

Try it

Circle collider bounce

A round body moves toward the floor with gravity off. At Restitution 0 it stops on contact.

Change Restitution from 0 to 1 to make the same collision bounce. Reset restores the original contact.

Starts the scene; open the example parameters to experiment.
Open in AegoDownload example project
Scene3 nodes
Ball
Transform
position[0, 3.19]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000d00")orderint1tintColor#f59e0bffsizeVec2[1, 1]
Floor
Transform
position[0, 4]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")orderint0tintColor#4b5563ffsizeVec2[18, 0.6]
Box Collider 2D
sizeVec2[18, 0.6]
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Camera 2D
zoomfloat40clearColorColor#111827ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue
Scriptmain.aes
package demo

import "aego/physics"

// The round body starts just above the floor and collides at the same speed
// in both versions. Restitution changes the actual physics contact response.
script CircleImpact {
    func Ready() {
        body := node.Get<Body2D>()
        body.SetVelocity(Vec2{0, 15})
    }
}

Fields

NameTypeDefaultDescription
OffsetVec2(0, 0)

Position of the shape in node space.

Is Triggerboolfalse

Detects overlaps and sends trigger events without pushing bodies apart.

Frictionfloat0.6

Resistance to sliding along other shapes; 0 is ice. Two shapes use the square root of the product.

≥ 0
Restitutionfloat0

Bounciness: 0 stops on impact, 1 bounces back at the same speed. Two shapes use the larger value.

≥ 0
Densityfloat1

Mass per square unit; gives the body its mass when Mass Mode is auto.

≥ 0
Radiusfloat0.5

Radius in units, before the node scale.

≥ 0

From a script

Make a ball bouncier every time it lands, up to a limit.

package game

import (
    "aego/math"
    "aego/physics"
)

script Bouncy {
    func OnCollisionEnter(other NodeRef, contact physics.Contact) {
        c := node.Get<CircleCollider2D>()
        c.Restitution = math.Min(c.Restitution+0.1, 0.9)
    }
}

Script events

Scripts on a node with this component receive these events from the Physics 2D module.