This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
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,606 points)

2 Answers

+2 votes
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 (381 points)
selected by

It's obvious in hindsight. Thanks!

This was very helpful to me--thank you so much!

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 (76 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 Frequently asked questions and 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 [email protected] with your username.