Scripting
The components are reached with node.Get<T>(); there is no module to import.
| Component | Methods | Signals |
|---|---|---|
| Motion2D | Move(x), MoveDir(dir), Jump(), JumpReleased(), Dash(velocity, seconds), AddVelocity(v), AddDisplacement(offset), Stop(), Teleport(position) |
Landed(speed), LeftGround(), Jumped(), HitWall(normal), HitCeiling() |
| Health | Damage(amount, source) bool, Heal(amount), Kill(source), Revive(hp), SetInvulnerable(seconds) |
Damaged(amount, source), Healed(amount), Died(source), Revived() |
| Hitbox2D | Activate(), Deactivate(), Pulse() |
Hit(target, damage) |
| Checkpoint2D | Reached(by) |
|
| Respawn | Trigger(), SetPoint(position) |
Respawned() |
| Pickup2D | Collected(by) |
|
| StateMachine | Go(state) bool, Is(state) bool, TimeIn() float |
Changed(from, to) |
A landing shake and a death screen:
func Ready() {
landed = node.Get<Motion2D>().Landed.Connect(OnLanded)
died = node.Get<Health>().Died.Connect(OnDied)
}
func OnLanded(speed float) {
if speed > 8 {
camera.Shake(0.3)
}
}
func OnDied(source NodeRef) {
GameOver.SetEnabled(true)
}
A short name like Health picks the project's own component first: a project that already has a Health keeps getting it, and node.Get<gameplay.Health>() reaches this one by its full name.