Files
retromariogodot/scripts/items/mushroom.gd
T
2024-07-29 23:30:26 +02:00

21 lines
453 B
GDScript

extends RigidBody2D
@export var speed = 70
@onready var ray_cast_left = $RayCastLeft
@onready var ray_cast_right = $RayCastRight
@onready var animation_player = $AnimationPlayer
func _physics_process(delta):
linear_velocity.x = speed
if ray_cast_left.is_colliding():
speed = abs(speed)
elif ray_cast_right.is_colliding():
speed = abs(speed) * -1
func _on_area_2d_body_entered(body):
body.grow()
speed = 0
animation_player.play("pickup")