I need to move the archer with input keys up or down, but the following code moves only archer - the bow doesn’t move with it.
function on_input(self, action_id, action)
local position=go.get_position()
local new_dir=vmath.vector3()
if action_id==hash("up") then
new_dir=vmath.vector3(position.x,position.y+3,0)
go.set_position(new_dir)
elseif action_id==hash("down") then
new_dir=vmath.vector3(position.x, position.y-3., 0)
go.set_position(new_dir)
end
You should move the bow inside the archer’s GO.
Keep in mind that you cannot move “the collection” itself in code, a collection is just a container.
So, all manipulations you should do with GO.
2: you cannot move sprite components inside a GO, you must move the GO itself
3: if it is possible I would go with two GO’s, one for archer and one for bow and then a collection containing a root GO with inside these two GO’s. In this way you move the root GO to move together the archer and the bow. And, if you want to move only the bow, you move the bow GO.