Hello, I can't get a powerup in my game to work, I know I am doing something wrong, but I also don't know what I have to do to get it working
Here is my code:
Player:
extends KinematicBody2D
var velocity = Vector2(0,0)
var crystals = 0
const SPEED = 100
const GRAVITY = 15
const JUMPFORCE = -300
func _physics_process(delta):
if Input.is_action_pressed("right"):
velocity.x = SPEED
$Sprite.play("Walk")
$Sprite.flip_h = false
elif Input.is_action_pressed("left"):
velocity.x = -SPEED
$Sprite.play("Walk")
$Sprite.flip_h = true
else:
$Sprite.play("Idle")
if not is_on_floor():
$Sprite.play("Air")
velocity.y = velocity.y + GRAVITY
func _on_speed_body_entered(body):
SPEED == 150
The Powerup:
extends Area2D
signal powerup_collected
func _on_crystal_body_entered(body):
$AnimationPlayer.play("bounce") #plays the bounce animation
emit_signal("coin_collected") #emits the coin_collected signal
set_collision_mask_bit(0,false) #sets the player collision mask to false so that we can't collide with it after we collect it
set_collision_mask_bit(0,false)
$SoundCollect.play() #plays the collection sound
func _on_AnimationPlayer_animation_finished(anim_name):
queue_free() #deletes itself after the bouncing animation finishes
Could someone please explain to me how do I get it to work?