0 votes

I am learning to devolop a 2d game. While coding I am getting these errors. I tried every way to solve it. but I can't. I searched on google but can't find a solution. I am stuck with this.

Godot version 3.4.3 Stable
in Engine by (12 points)

2 Answers

+1 vote

Check the top of the script and make sure the first line is "extends Sprite".

If you originally made the script on a KinematicBody2D and later put the script on a Sprite, then the top line will still be "extends KinematicBody2D" but it needs to be changed to "extends Sprite".

by (180 points)
0 votes

I recommend you use composition versuses inheritance.

Basically, create a sprite node and give it a kinematic2d child or just have a node and have it have a sprite and kinematic2d as children. By doing this you can have both thing in a single node without needing to inherit two scripts.

Code speaks through signals or direct calls
Sprite -> Sprite Script
-> Kinematic2d -> Current Script

Node2D -> Connecting Kinematic and Sprite or Other Stuff
-> Kinematic2d
-> Sprite

by (98 points)
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.