This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

animationsprite.animation = "jab"

im new to coding and im not sure what to look up.
ill be looking stuff up in the mean time.

im making a 2D fighter, and i dont see many others doing it.

Godot version v3.2.3
in Engine by (12 points)

2 Answers

+1 vote

You only posted two lines of code, but I'm guessing that you have some code that sets the animation to an idle animation or no animation at all if there's no button pressed. A simple solution to this would be to have a boolean that keeps track of whether the player is attacking or not and not play the idle/no animation if the player is attacking.

by (8,580 points)

Okay well can you put the correct scripts on the correct nodes?

You have the script on a Node2D instead of a KinematicBody2D so you should probably move it to the correct place.

probably, but ive already started a duplicate project. currently having the same scenario. i can do my jab animation only when i jump.

extends KinematicBody2D

const SPEED = 100
const GRAVITY = 10
const JUMP_POWER = -150
const FLOOR = Vector2(0, -1)

var velocity = Vector2()

var on_ground = false

func physicsprocess( _delta):

if Input.is_action_pressed("ui_left"):
    velocity.x = -SPEED

elif Input.isactionpressed("moveright"):
velocity.x = SPEED
if on
ground == true:
velocity.x = 0

if Input.is_action_pressed("ui_up"):
    if on_ground == true:
        velocity.y = JUMP_POWER
        on_ground = false

if Input.is_action_pressed("attack_jab"):

velocity.y += GRAVITY

if is_on_floor():
    on_ground = true
    on_ground = false 

velocity = move_and_slide(velocity, FLOOR)

this is my current script. all animations play properly except for jab..

this is the current error message:

E 0:00:59.239   emit_signal: Error calling method from signal 'animation_finished': 'KinematicBody2D(': Method not found..

<C++ Source> core/object.cpp:1260 @ emit_signal()

Looks like you connected the signal but deleted the function that it was connected to. You need to recreate the function.

it wasnt doing anything when i applied it

Well, then remove the signal to prevent the error then.

+1 vote

Try this"jab")

Check out the docs for more info on AnimationPlayer.

by (130 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.