How to check for collision with instance of PackedScene?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gameaddict24

I have a Ball scene and a separate Player scene. I want to check for collisions against any instance of the Player scene, but when I run the following code on the Ball’s KinematicBody2D:

var Player = preload("res://Player.tscn")

func _physics_process(delta):
	col = move_and_collide(velocity)
	if col and col.collider is Player:
		print('hit player')

I get this error upon collision: Right operand of 'is' is not a class (type: 'PackedScene').

How do I get the class from a PackedScene? Am I going about this correctly?

:bust_in_silhouette: Reply From: brainbug
const PlayerClass = preload(…//"Player.gd")


if something is PlayerClass :

or in player.gd

extends …
class_name Player