Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid get index 'interactive_object_detected' (on base: 'Nil') #197

Closed
Strongground opened this issue May 23, 2024 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@Strongground
Copy link

Strongground commented May 23, 2024

Cogito and Godot Engine Version:
Cogito 9f4be78
Godot 4.2.1

Description:
When first instantiating CogitoPlayer prefab and Player_HUD as well as PauseMenu, setting their references, but have the node order so that the player comes below the UI nodes, the scene will crash with the error message "Invalid get index 'interactive_object_detected' (on base: 'Nil')".

Reproduction steps:

  1. Make sure COGITO folder is present in project.
  2. Create new 3D scene.
  3. Instantiate player prefab.
  4. Instantiate Player_HUD node.
  5. Instantiate PauseMenu.
  6. Make sure in the node order, the Player is below the UI nodes.
  7. Start game.

Expected behavior:
The game should start, the reference to player_interaction_component should not get lost.

@Strongground Strongground added the bug Something isn't working label May 23, 2024
@Strongground
Copy link
Author

I tried for hours to compare DEMO_Lobby and my simple test scene bit for bit, but I can't find the difference that makes my scene crash (see description above) and the DEMO level not. Please enlighten me! D:

@Phazorknight
Copy link
Owner

Can you confirm that you set the references to the HUD and PauseMenu in the Player node?

See also this video for reference where I do a quick scene setup from scratch: https://www.youtube.com/watch?v=KXcOj4LhOrY

@Strongground
Copy link
Author

Strongground commented May 23, 2024

My scene is set up almost exactly like in the video, only difference is some additional meshes (e.g. StaticBody+Mesh+Collider instead of CSGBox) and some World Environment settings concerning the skybox that shouldn't touch Cogito. For the sake of it I recreated the scene exactly as in the video, and it runs! Then I deleted PauseMenu, Player_HUD and player completely from my first scene and added them new. My scene now also runs.
I cannot tell what difference there is between the ones I added yesterday and today - all references are set in both cases.

I guess it just goes to show that you shouldn't try to force progress if you are tired.

@Strongground
Copy link
Author

Strongground commented May 23, 2024

A minute after closing the bug I discovered what the problem is! Loading order!
Place PauseMenu and Player_HUD above the CogitoPlayer and the problem is perfectly reproducable. :)
Place it below and everything works. You must decide if this warrants a fix - I guess saying that the UI nodes need to be placed after the player by convention would also work.

@Phazorknight
Copy link
Owner

Oh yeah, sorry, I always forget to mention that the nodes need to be in this order.
The Cogito documentation mentions it, but it's still not great.

We're discussing how to improve the whole Player tscn setup in this thread #179 , so hopefully this will improve in the near future.

@Phazorknight
Copy link
Owner

Just a quick update, the new commit 64c020d now unifies this all into a single Player.tscn .
Going to close this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants