Circle Collider 2D
Circle shape. Needs a uniform node scale.
component physics.CircleCollider2D
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.
Scene3 nodes
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
| Name | Type | Default | Description |
|---|---|---|---|
| Offset | Vec2 | (0, 0) | Position of the shape in node space. |
| Is Trigger | bool | false | Detects overlaps and sends trigger events without pushing bodies apart. |
| Friction | float | 0.6 | Resistance to sliding along other shapes; 0 is ice. Two shapes use the square root of the product. ≥ 0 |
| Restitution | float | 0 | Bounciness: 0 stops on impact, 1 bounces back at the same speed. Two shapes use the larger value. ≥ 0 |
| Density | float | 1 | Mass per square unit; gives the body its mass when Mass Mode is auto. ≥ 0 |
| Radius | float | 0.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.
OnCollisionEnter— Runs after the physics step in which this body started touching other.OnCollisionExit— Runs when the bodies stop touching, including when one of them is destroyed or disabled. Contact.Point is the last known point.OnCollisionStay— Runs after every later physics step while the bodies keep touching. It costs nothing when no script declares it.OnTriggerEnter— Runs when other's collider entered a trigger of this body, or this body entered other's trigger.OnTriggerExit— Runs when the overlap with a trigger ends.
Related guides
- Components These components make a node part of the simulation.
- Physics 2D Aego simulates 2D rigid bodies with its own solver.