extends KinematicBody var hit_acceleration = 10 var hit_speed = 100 var velocity = Vector3() var movement = Vector3() var direction = Vector3() var gravity_vec = Vector3() onready var hurtbox = $Hurtbox/HeadCollision onready var hitbox = $HitBox/CollisionShape onready var animation_player = $AnimationPlayer onready var Explosion = $Explosion func _ready(): animation_player.play("floating") var rng = RandomNumberGenerator.new() rng.randomize() animation_player.seek(rng.randf_range(0.0,3.0)) animation_player.stop() func _physics_process(delta): velocity = velocity.linear_interpolate(direction * hit_speed, hit_acceleration * delta) movement.x = velocity.x movement.y = velocity.y movement.z = velocity.z move_and_slide(movement, Vector3.UP) if get_slide_count() > 0: var collision = get_slide_collision(0) if collision != null: direction = direction.bounce(collision.normal) func get_slapped(slap_level, slap_kill, slap_vector): if slap_level >= slap_kill: animation_player.stop() direction = slap_vector * slap_level hurtbox.disabled = true hitbox.disabled = false func get_shot(hitboxOwner): hitboxOwner.die() Explosion.play() die() func die(): queue_free()