Is packed scene equals with an instanced object's scene?

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

I have a packedScene and I want to do something if the body is instanced from the same scene.
(I do not want to use, groups.)

Pseudo code:
export(PackedScene) var from

func _on_body_entered(body):
if body.get_scene_path() == from.get_scene_path()
doSomething()

:bust_in_silhouette: Reply From: BraindeadBZH

I think a better option is to use the is keyword to test the type of the nodes.

Godot says: nope

Right operand of ‘is’ is not a class (type: ‘PackedScene’)

I also changed many things, but in generally IS operator/expression throws error like that.Right operand of ‘is’ is not a class (type: ‘Rigidbody2D’)

Fun part: if body is body throws error.

Probably something fundamental is the problem.

DavidPeterWorks | 2019-08-29 07:02

:bust_in_silhouette: Reply From: DavidPeterWorks

It is ugly but it works. It requires scripts to operate.

func isEqual(a, b):
	if (a != null && a.get_script()!=null && b != null && b.get_script()!=null):
		if (a.get_script().resource_path == b.get_script().resource_path):
			return true
		
	return false