-
|
I add a component first and then make a relation assignment, but mapper := ecs.NewMap2[ChildOf, Position](&world)
mapperChildOf := ecs.NewMap[ChildOf](&world)
parent := world.NewEntity()
child := mapper.NewEntity(&ChildOf{}, &Position{})
mapperChildOf.SetRelation(child, parent)
// panic: relations must be fully specified
world := ecs.NewWorld(10)
mapper := ecs.NewMap2[ChildOf, Position](&world)
mapperChildOf := ecs.NewMap[ChildOf](&world)
parent := world.NewEntity()
parent2 := world.NewEntity()
child := mapper.NewEntity(&ChildOf{}, &Position{}, ecs.Rel(0, parent))
mapperChildOf.SetRelation(child, parent2) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
|
Hi @setanarut! Try this: parent := world.NewEntity()
child := mapper.NewEntity(&ChildOf{}, &Position{}, RelIdx(0, parent)) |
Beta Was this translation helpful? Give feedback.
-
|
What I mean is that SetRelation() does not do what its name says. |
Beta Was this translation helpful? Give feedback.
-
|
@setanarut I would like to leave answered discussions open so others with potential similar questions have a better chance finding them. |
Beta Was this translation helpful? Give feedback.
I think it does, and this is a misunderstanding. When adding a relation component (or creating entities with such), you must specify the target.
After that, you can use
Map.SetRelationto move the entity to a different target.Please double-chack that the error really comes from
Map.SetRelation, not frommapper.NewEntity.