Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | MightyRat |
This is my script for a projectile. After the second timer (the one that doen’t work) the player should have his speed back (the projectile debuffs for a short time). The script:
extends Area2D
const SPEED = 4
var velocity = Vector2()
var direction = 1
var impact = false
func _ready():
pass
func set_fireball_direction(dir):
if impact == false:
direction = dir
if dir == -1:
$AnimatedSprite.flip_h = true
func _physics_process(delta):
if impact == false:
velocity.x = SPEED + delta * direction
translate(velocity * direction)
$AnimatedSprite.play("shoot")
func _on_VisibilityNotifier2D_screen_exited(): #quando esce dallo schermo viene cancellata
queue_free()
func _on_PlantAttack_body_entered(body):
impact = true
$AnimatedSprite.play("impact")
if "Enemy" in body.name:
body.dead()
$Timer.start()
if "Player" in body.name:
body.ACCELERATION = 10
$Timer2.start() #Timer doesn't start
body.dead()
func _on_AnimatedSprite_animation_finished():
impact = false
func _on_Timer_timeout():
queue_free()
func _on_Timer2_timeout():
get_parent().get_node("Player").ACCELERATION = 50 #This line doesn't work
print("ciao")