|Topic was automatically imported from the old Question2Answer platform.
I am relatively new to Godot and programming, but I have tried just about everything and nothing has worked. Here is my problem:
I want to make a simple walk cycle animation. I am using modified code from the Godot documentation for 2D sprite animation1. My full AnimatedSprite.gd file looks like this:
My AnimatedSprite is a child of a KinematicBody2D, and the AnimatedSprite has 4 animations in it: one left-facing walk cycle, one right-facing walk cycle, one neutral idle animation facing right, and one neutral idle animation facing left. I get no errors in my AnimatedSprite.gd code until I run the game, upon which I receive this fatal error that crashes the game as soon as the Godot logo appears:
Script inherits from native type 'KinematicBody2D', so it can't be instanced in object of type: 'AnimatedSprite'. This error supposedly comes from the first line of my code,
extends KinematicBody2D. So I try to fix the error by changing
extends KinematicBody2D to
extends AnimatedSprite. Upon doing that, I get another fatal error that crashes the game at the Godot logo:
Attempt to call function 'play' in base 'null instance' on a null instance. Looking at this further in the debug console, this error is further refined as
get_node: Node not found: AnimatedSprite. This isn’t right, because I have an AnimatedSprite node that this script is attached to.
If anyone can help with this, I would really appreciate it. I have been working on debugging this for about 2 days now and nothing has worked. If anyone would like to take a look at the project file for further inspection of my code, let me know. Thank you for your help.