0 votes

I have a BossTrigger node that I'm using to trigger introductory animations in my Boss nodes. The trigger is essentially just an Area2D. In my boss room, I want to place a BossTrigger and associate that trigger with a Boss that is also in that room.

Currently, in my BossTrigger script, I have

export(NodePath) var associated_boss

I then manually assign my boss to the trigger in the editor.

Unfortunately, when my player enters the trigger and my on_trigger_entered() function is called, I'm getting an error that there's no index 'animation_player' on base 'NodePath'. I'm certain my boss has an variable called animation_player, so I'm not sure what the issue could be.

Any ideas?

in Engine by (1,539 points)

2 Answers

+1 vote
Best answer

If you are exporting NodePath then you have to use that as argument for get_node

export(NodePath) var associated_boss
var boss = get_node(associated_boss)
boss.animation_player
by (378 points)
selected by

It's obvious in hindsight. Thanks!

0 votes

Hey, well NodePath is just a path to the node, is meant to be used with get_node().
I'd say try using export(Node) var associated_boss instead... that or some other type, not sure.
You could always use get_node() if it doesn't work but it should.

by (73 points)

You can't use Node as export argument.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.