A game object file not having other game objects as children?

For example, I created chess_piece.go in order to spawn it to many pieces. In this game object I have a sprite which I want to do animation on it (rotation). As far as I researched, we only do animation on game objects, not sprites. However when I right click on the game object, there’s no option for adding a game object on it.

My question is why I can’t do it on game object file while game objects in a collection can. Is there any good way to have animation on a part of a game object not a whole of it?

Please prefer this image to be clearer what I mean :slight_smile:

To create a hierarchy of game object you need to use a collection.

3 Likes

Okay, I’m gonna create a chess_piece.collection and spawn it :smiley:
Actually I want something small just like a game object instead of a collection

A collection isn’t anything “big”, it is literally just a collection of game objects. In fact, you can’t reference a collection after it’s been spawned, only the game objects it contains. Don’t be afraid of using collections!

4 Likes

You can do flip book, model and property animations. This includes ‘on sprites’ with rotation. See:

1 Like

Could you give me an example of rotation animation on sprite? Thank you!

You don’t do animation specifically on the sprite. Sprites only support flipbook animations.
You can however rotate the parent game object, using e.g.

go.animate(url_to_go, "euler.z", go.PLAYBACK_LOOP_FORWARD, 360, go.EASING_LINEAR, 2.0)

1 Like

I am confused, the Defold manual contains the example:

local function play_idle_animation(self)
    if self.dodge then
        sprite.play_flipbook("#sprite", hash("dodge_idle"))
    else
        sprite.play_flipbook("#sprite", hash("idle"))
    end
end

which made me think that animations are done ‘on the sprite’, or more specifically the meta-data of the sprite.

1 Like

Yes, but we are talking about different types of animations. Flippbook animations are not the same as property animations. Since they wanted to use rotation, then that would be a propety animation, using go.animate