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

is there a way to make a simple attack system just with AnimatedSprite ?

in Engine by (18 points)

This question is much too generic to answer. "attack system" can mean many things. Please provide more information about exactly what you're hoping to accomplish, and you'll be much more likely to get a response.

I made 2 different player and I want to the player to fight against
I have attack animation

I Have a AnimatedSprite and another Player and I want to press on a key and the player attack and hit the other there is my code if you want `extends KinematicBody2D

var collision = 0
const UP = Vector2(0, -1)
const GRAVITY = 20
var SPEED = 200
const JUMPHEIGHT = -400
var motion = Vector2()
var attack = 0
var health
var jumpCount = 0
export var extraJumps = 1
var jumpForce = -400
func _physics
process(delta):
motion.y += GRAVITY
var friction = false
if Input.isactionpressed("uiright"):
motion.x = SPEED
$Sprite.play("Walk")
$Sprite.flip
h = false
elif Input.isactionpressed("uileft"):
motion.x = -SPEED
$Sprite.play("Walk")
$Sprite.flip
h = true
else:
motion.x = 0
$Sprite.play("Idle")
if Input.isactionjustpressed("uiup") && jumpCount < extraJumps:
motion.y = jumpForce
jumpCount += 1
$Jump.play()
if isonfloor():
jumpCount = 0
motion = moveandslide(motion, UP)
pass
if Input.isactionjustpressed("dash"):
dash()
if SPEED == 400 and friction == false:
$Sprite.play("Dash")
if Input.is
actionjustpressed("attack"):
attack1()
if attack == 1 and onArea2Dareaentered(Area2D) and collision == 1 :
$Sprite.play("Attack")
$Sprite.stop(true)
func dash():
SPEED = 400
$Timer.start()
$Dash.play()
func onTimer_timeout():
SPEED = 200

func onArea2Dareaentered(Area2D):
health = 10
func attack1():
attack = 1
$Sprite.play("Attack")
$Sprite.pause_mode`

Please log in or register to answer this question.

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.