Problem about the Animated Sprite.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nick888

First I created a simple sprite and i wrote and the Script code. When I compiled the code all was good. I had no problem with the execution of sprite. But, when i replaced the sprite with an Animated Sprite and i compiled the code then the Animated Sprite was not responding and it was not moving. What is really the problem here?

Thank you.

You should share your code. How else to tell what’s wrong?

kidscancode | 2019-04-25 20:35

This is the code, but I suspect that the problem may be related about the settings of AnimatedSprite or something…

extends KinematicBody2D

var motion=Vector2()
const UP=Vector2(0,-1)
export var speed=200
export var gravity=10
export var jump_force=-400


func _physics_process(_delta):
   motion.y +=gravity
   if Input.is_action_pressed("ui_right"):
	    motion.x = speed
   elif Input.is_action_pressed("ui_left"):
	    motion.x = -speed
   else:
	     motion.x=0
		
   if is_on_floor():
     if Input.is_action_just_pressed('ui_up'):
           motion.y=jump_force
   motion=move_and_slide(motion,UP)
   pass

Nick888 | 2019-04-26 03:33

My code has the correct underscores in the commands they need them, but while i did copy and paste the code the frame of the message didnt appeared them.

Nick888 | 2019-04-26 03:42

That’s because you have to format the code by putting four spaces in front of it, similar to reddit and other sites. I’ve edited your post. The code seems fine - what do you mean by “not responding”? Did you add a SpriteFrames to the AnimatedSprite? Does the animation appear?

kidscancode | 2019-04-26 04:04

Thank you.
Yes i did all of that about SpriteFrames.Yes, the animation appears but its just stuck on the air.No movements…

Nick888 | 2019-04-26 04:13

Do you have a collision shape defined?

kidscancode | 2019-04-26 04:15

Totally yes.This is the paradox here…

Nick888 | 2019-04-26 04:19

The code looks fine. Any way you can zip the project and share?

kidscancode | 2019-04-26 04:30

Yes. I will need to create an executable file first ,right?

Something else that i noticed is that althought i have export var variables in my code, in the Inspector of the player doesnt appears the Script Variables.

Nick888 | 2019-04-26 04:38

No, just zip up the project folder. Exporting the project wouldn’t let me see how your scene is set up.

Are you sure the script is still attached to the player node?

kidscancode | 2019-04-26 04:40

To tell you the truth i start to realize that the script is not attached to the player node.I will send you later a zip file if i see that i cant find a solution between the player node and the script.
Thank you very much so far!

Nick888 | 2019-04-26 04:54

The life is weird sometimes.It worked!Indeed, the script was not attaching with the player node!!!
I would like to thank you again so much about your replies!

Nick888 | 2019-04-26 05:16