Camera not following player and non fatal errors in output after migrating beta 3 to 2.0
Opened this issue · 3 comments
Bug description
After migrating my project from beta 3 to 2.0 I noticed some error messages in the console. They are not fatal and can be ignored, but the main problem is that the camera does not follow the player. I decided to make a clean project, but there are errors there too, and the camera is also broken.
Steps to reproduce
Get Godot 4.3, create new project, extract there the latest popchiu 2.0, activate plugin and run wizard with:
*native resolution - 1920x1080;
*game type - 2d;
*gui - simple click.
Steps to reproduce the behavior:
- Create new character
- Click on InteractivePolygon
- See in output error:
res://addons/popochiu/editor/gizmos/gizmo_clickable_plugin.gd:47 - Cannot call method 'get_class' on a null value. - Add any sprite and make the character main
- Create new room
- Add new BG prop
- Click on the prop scene to edit it
- See in output error:
editor/editor_data.cpp:1214 - Condition "!p_node->is_inside_tree()" is true. - Add a texture for BG prop larger than native window resolution (I use 3840x1080 px)
- Add walkable area with some polygon large enogh to extend beyond the starting game viewport
- Add character to room and place it over walkable area
- Run game and see that camera doesn't follow the player.
Also, if you load the example game project, the camera works in the outside room, but there are also output errors (after clicking and checking some of rooms, props or characters):
res://addons/popochiu/editor/gizmos/gizmo_clickable_plugin.gd:47 - Cannot call method 'get_class' on a null value.
res://addons/popochiu/editor/canvas_editor_menu/popochiu_canvas_editor_menu.gd:145 - Invalid type in function 'get_first_child_by_group' in base 'GDScript'. The Object-derived class of argument 1 (previously freed) is not a subclass of the expected argument class.
res://addons/popochiu/engine/objects/character/popochiu_character.gd:952 - Invalid call. Nonexistent function 'update_characters_position' in base 'Nil'.
Expected vs observed behavior
No errors in output, camera follow the player.
Environment information (please complete):
- Windows 11 Pro
- Godot version 4.3
- Popochiu 2.0
I have been using room scrolling in my game.
I have recorded a quick youtube video on how I do it.
I have been using room scrolling in my game.
I have recorded a quick youtube video on how I do it.
Maybe I didn't notice that the camera doesn't follow the player before (I tried the new background already in the new version), but in the previous beta build there were definitely no errors.
Any tutorial would be good, because the documentation says that it should work out of the box. And it works in the demo game somehow, but not in my project. So maybe I'm doing something wrong... Unfortunately, YouTube says that the video at your link was deleted.
Addition:
I followed your guide and realized that in the "Room Size" section I need to specify the size of the background image, and then manually set the limits on each side that the camera cuts off. After that, everything worked. Thank you very much!
The only thing here right away. I have a picture of 3840x1440 and a resolution of 1920x1080. If, for example, the background is on the far left border of the camera (and game screen) and I set the limits L: 0, R: 3840, T: -180 and B: 1260. The camera movement up and down works correctly, but left and right does not. The camera goes beyond the screen border immediately at the start of the room, and the character cannot reach the right edge. If you set the background in the camera center, then these problems do not exist. Apparently, this setting option is not correctly taken into account in the camera code.
It should work I posted an update and edited the link. I also added it to the faq on discord channel