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
motion.y += GRAVITY
var friction = false
if Input.isactionpressed("uiright"):
motion.x = SPEED
h = false
elif Input.isactionpressed("uileft"):
motion.x = -SPEED
h = true
motion.x = 0
if Input.isactionjustpressed("uiup") && jumpCount < extraJumps:
motion.y = jumpForce
jumpCount += 1
if isonfloor():
jumpCount = 0
motion = moveandslide(motion, UP)
if Input.isactionjustpressed("dash"):
if SPEED == 400 and friction == false:
if attack == 1 and onArea2Dareaentered(Area2D) and collision == 1 :
func dash():
SPEED = 400
func onTimer_timeout():
SPEED = 200

func onArea2Dareaentered(Area2D):
health = 10
func attack1():
attack = 1

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.