Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Abb1x |
is there a way to make a simple attack system just with AnimatedSprite ?
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.
kidscancode | 2019-12-14 17:33
I made 2 different player and I want to the player to fight against
I have attack animation
Abb1x | 2019-12-15 00:37
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 JUMP_HEIGHT = -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.is_action_pressed(“ui_right”):
motion.x = SPEED
$Sprite.play(“Walk”)
$Sprite.flip_h = false
elif Input.is_action_pressed(“ui_left”):
motion.x = -SPEED
$Sprite.play(“Walk”)
$Sprite.flip_h = true
else:
motion.x = 0
$Sprite.play(“Idle”)
if Input.is_action_just_pressed(“ui_up”) && jumpCount < extraJumps:
motion.y = jumpForce
jumpCount += 1
$Jump.play()
if is_on_floor():
jumpCount = 0
motion = move_and_slide(motion, UP)
pass
if Input.is_action_just_pressed(“dash”):
dash()
if SPEED == 400 and friction == false:
$Sprite.play(“Dash”)
if Input.is_action_just_pressed(“attack”):
attack1()
if attack == 1 and _on_Area2D_area_entered(Area2D) and collision == 1 :
$Sprite.play(“Attack”)
$Sprite.stop(true)
func dash():
SPEED = 400
$Timer.start()
$Dash.play()
func _on_Timer_timeout():
SPEED = 200
func _on_Area2D_area_entered(Area2D):
health = 10
func attack1():
attack = 1
$Sprite.play(“Attack”)
$Sprite.pause_mode`
Abb1x | 2019-12-15 02:53