0 votes

Hello all!
After working on a game, the (animated) sprite suddenly dissapeared and I have no idea what I have done. The collision box is still there, but I can't move the character when starting the game, and the following error is given, once the skeleton mob collides with the player:

Invalid get index 'health' (on base: 'KinematicBody2D').

Is there any way to find out from the screenshot I attached, or is more information needed? I also included screenshots of the code, where the mistake is evoked, and where the player's health variable is initiated.
If anyone helps me by any virtue, I would be exultant.


in Engine by (14 points)

I fixed the visibility issue - somehow the modulate property of the root node "player" was altered. However, I still can't move the player, and the same error is given.

1 Answer

0 votes

By the looks of that code, you should be referencing target.health, not player.health (assuming your player has a health variable).

by (12,473 points)

Both "target" and "player" have the same address (1466), so that's not the issue. Tried to change it to "target" though, but the same error is given, and the player sprite is still invisible and is unable to move (the camera stays in one place). However, the skeleton's AI sees it, and follows it, before the game crashes and the mentioned error is given.

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.