Hi,
I've setup a world and added 3 Entities with movement component.
collection.go:34: collection Add:{"Speed":0.008888888888888889,"Course":145}
collection.go:34: collection Add:{"Speed":0.0033333333333333335,"Course":120}
collection.go:34: collection Add:{"Speed":0.0033333333333333335,"Course":45}
I'm trying to use an Input system similar to your example to get and change speed for an entity.
type MoveChange struct {
ecs.FreeDisposableComponent[MoveChange]
}
import (
"github.com/zllangct/ecs"
"astt-server/components"
)
type MoveChangeSystem struct {
ecs.System[MoveChangeSystem]
}
func (mc *MoveChangeSystem) Init() {
ecs.AddRequireComponent2[components.Movement, components.MoveChange](mc)
}
func (mc *MoveChangeSystem) PreUpdate(event ecs.Event) {
iterMovement := ecs.GetInterestedComponents[components.Movement](mc)
if iterMovement == nil {
return
}
for mov := iterMovement.Begin(); !iterMovement.End(); iterMovement.Next() {
println(mov.Speed, mov.Course)
println(mov.Owner().Entity())
}
}
I get 3 values printed - but they're all the same.
+8.888889e-003 +1.450000e+002
-7673762469411480564
+8.888889e-003 +1.450000e+002
-7673762469411480564
+8.888889e-003 +1.450000e+002
-7673762469411480564
How do I get the data for each separate entity?
Thanks.
Hi,
I've setup a world and added 3 Entities with movement component.
I'm trying to use an Input system similar to your example to get and change speed for an entity.
I get 3 values printed - but they're all the same.
+8.888889e-003 +1.450000e+002
-7673762469411480564
+8.888889e-003 +1.450000e+002
-7673762469411480564
+8.888889e-003 +1.450000e+002
-7673762469411480564
How do I get the data for each separate entity?
Thanks.