0 votes

I am very new to godot and game engine or programming. I would appreciate if someone could teach me how to display sprite on the screen.

I made player animation using Animation Player inside a scene called PlayerAniamtion. And I instantiated that scene as a child of KinematicBody2D inside another scene. However, the sprite does not show up.

Godot version version3.3.3
in Engine by (65 points)
edited by

1 Answer

0 votes

It looks from the error as though you havent actually added a sprite to the animation player.

The documentation is here

https://docs.godotengine.org/en/stable/tutorials/2d/2d_sprite_animation.html

You will see in the editor there is a section called frames, you have to add the sprites there. Hope this helps.

by (2,001 points)

Thank you for the comment, but sprites are already in frames.
I reuploaded the gif so please check

Oh okay so I think I can see what is going wrong here. You need to create the whole player as a single scene not add a node2d with a bunch of animations hanging off of it.

Nice looking animations by the way, they look nice.

What you want to do is create a scene (call it player or something) but the top node should be a kinematic body 2d. The under that have a collision shape and an animation player. When you instantiate a player you call the whole set of nodes then with the appropriate scripts.

You should only need one animation player node, within that node you can add all of the animations and name them accordingly. To be honest it is the structure of the nodes which is causing you a problem here.

The documentation i linked before outlines this so if you create a test project and just follow the documentation that should show you how to do it in your main project.

It worked!! I made new scene where have kinematicbody2d only. and I just instantiated animation-scene, and i can see the sprite! Thank You so much.

But, i still do not understand why the sprite didnt show up when kinematicbody2d was under 2d node.

Yeah node structure is important not only for being able to call the right functions in scenes lower in the scene tree but also because some nodes dont have certain functions that other nodes have.

The documentation explains it all here

https://docs.godotengine.org/en/latest/getting_started/step_by_step/nodes_and_scenes.html

hopefully that will help, getting the node structure correct is very important in godot.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.