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

Error node_to_set.position when switch scenes #373

Closed
juliusspeak opened this issue Feb 22, 2025 · 4 comments
Closed

Error node_to_set.position when switch scenes #373

juliusspeak opened this issue Feb 22, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@juliusspeak
Copy link

Cogito and Godot Engine Version:
cogito beta, godot 4.3.1.rc

Description:
When switching scenes, an error occurs while loading cogito_vehicle, and sometimes while loading other objects. If you ignore the error and continue (F12), the object will still be in the correct place.

Screenshots:

Image

@juliusspeak juliusspeak added the bug Something isn't working label Feb 22, 2025
@juliusspeak
Copy link
Author

It seems that this error is caused by the fact that I had added
self.add_to_group("Persist") in cogito_vehicle.

@juliusspeak
Copy link
Author

I get an error related to the garbage truck (cogito_vehicle) when loading from the scene Building0Room1 to Building0Room0. These scenes don’t have the garbage truck; it’s in a completely different scene, but for some reason, it still tries to load here.

Image

@Phazorknight
Copy link
Owner

This is probably fixable but depends a bit on what behaviour you're aiming for.

First, undo adding cogito_vehicle to the "persist" group, as it inherits from cogito_sittable which is already in a saving-related group ("save_object_state")

It's probably helpful to fully understand how these two groups work within Cogito's save system, and this will help you add the desired behaviour:

"Persist" group is used for objects that can be removed from scenes (stuff like items, enemies, destructables)
When Cogito loads a scene that has a temporary save state, it actually deletes all the "Persist" objects from the cogito_scene first, then adds them back in based on the data in the scene_state.
This requires that each object has valid state_data (and missing state_data is what seems to be causing your error)

"save_object_state" group on the other hand is used for objects that are always present within a cogito_scene (like doors, switches, etc). When Cogito loads a scene, it overwrites any objects data in this group with the saved state_data (so for example if a door was left open, a switch was left on/off etc).
This can also include basic information like position/rotation etc.

If you need specific custom behaviour for your object's state that's derived from the cogito_sittable or the cogito_vehicle, I'd probably overriding what state_data is saved to fit your needs, by overriding the save() function.

state_data is a dictionary, so it's very easy to add custom values that will get saved/loaded.
As a reference, this is the default save() function for sittables (which is also used by vehicles)

Image

@juliusspeak
Copy link
Author

It seems there is no problem

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