system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
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()
system
2
|
|
|
|
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
system
3
|
|
|
|
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