32 lines
453 B
Plaintext
32 lines
453 B
Plaintext
package lab
|
|
|
|
import (
|
|
"aego/input"
|
|
"aego/scene"
|
|
)
|
|
|
|
script Spawner {
|
|
@export
|
|
var Camera NodeRef
|
|
|
|
@export
|
|
var Crate AssetRef<Prefab>
|
|
|
|
@export(min=1, max=64)
|
|
var Limit int = 16
|
|
|
|
var spawned int
|
|
|
|
func Update(dt float) {
|
|
if Camera == nil || spawned >= Limit || !input.MousePressed(input.MouseLeft) {
|
|
return
|
|
}
|
|
crate := scene.Instantiate(Crate, nil)
|
|
if crate == nil {
|
|
return
|
|
}
|
|
crate.SetPosition(input.MouseWorld())
|
|
spawned++
|
|
}
|
|
}
|