Complications with AnimationPlayer and not understanding Frames in Godot

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

How do I access a certain frame of a specific animation in my player?

Second question:
Why is my Player not running my Jump animation? “Preparando Pul”?

Conclusion: I want to make it use the “NO AR” animation on frame 2 of the “Preparando Pul” animation, by activating velocity.y = jump_speed.

Fourth Doubt:
How do I make him fall…?
When he starts jumping, he doesn’t stop…


extends KinematicBody2D

var state_machine
var speed = 100.0
var velocity = Vector2.ZERO
onready var _animated_gun = $MP5
var jump_speed = -350
var grv = 10

func _ready():
	state_machine = $AnimationPlayer

func _physics_process(_delta):
	velocity.y += grv
	if Input.is_action_pressed("ui_left"):
		$Sprite.scale.x = -1
		$MP5.scale.x = -1
		velocity.x = -1 * speed
	if Input.is_action_pressed("ui_right"):
		$Sprite.scale.x = 1
		$MP5.scale.x = 1
		velocity.x = 1 * speed
	if Input.is_action_pressed("ui_right") || Input.is_action_pressed("ui_left"):
		if Input.is_action_pressed("SHIFT"):
			speed = 50"Walking")"MP5_ANDANDO_SHIFT")
			speed = 100     
	if Input.is_action_pressed("ui_up"):"Preparando Pul")
		if state_machine.getFrames() == 2:"NO AR")
			velocity.y = jump_speed
		velocity.y += grv
	##if state_machine.current_animation == "Preparando Pul":
	velocity = velocity.normalized() * speed
:bust_in_silhouette: Reply From: aXu_AP

For your first question, use seek function."my_animation") # Animation .5 seconds in

AnimationPlayer handles animations based on time stamps, not by frames. If you want to seek in certain frame calculate it’s time: frame / frames_per_second.

As for the rest, please ask only one question in one post, it makes the questions more searchable. Somebody else might have the same problem as you in future, but skip this post as it’s title doesn’t relate to the rest. Check the readme.

Thank you for you answer. I will certain do it all for sure.

JPixelArt | 2022-09-20 12:21

Doesnt exist function seek in Animated Sprite?
Sorry, i dont know if my post take too long to be posted. But my animations are played by AnimatedSprite now.

JPixelArt | 2022-09-20 12:37

In AnimatedSprite, animation is frame based, and you can set the current frame by setting frame property.

aXu_AP | 2022-09-20 15:14