Hello all! I am a really new Adventure Creator user (albeit a Unity developer for years), so bear with me if my understanding is a bit off.
So I am starting a new project using Adventure Creator and I want it to be in a 2D first-person view without the player character moving around on the screen. I have picked up the GameCamera2DDrag
script for that, which seems like a good fit in what I want to achieve.
I am trying to get the save/load system to work, so that once a save is loaded, the camera would move instantly to the stored position it was at the moment the game was saved.
Contrary to how the 2D demo works, where the camera position is restored correctly, I can't get the position of GameCamera2DDrag
to be loaded properly (even though I noticed that it is in fact stored in the save file).
I was able to do some debugging and noticed that the reason the camera position is restored in the 2D demo is because it uses a GameCamera2D
, which -as a class- overrides the MoveCameraInstant()
method that changes the position of the camera based on the position of the player character (Target
), which my project does not have.
Is there a way I can make the position of the GameCamera2DDrag
to be properly restored when the game loads?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
I have also tried using the
RememberTransform
component and although the transform is stored, it is not restored.Welcome to the community, @stelabouras.
For a camera that has no target, the position of the camera will need to be saved via a Remember component.
Remember Transform ought to save/restore the camera's position - but it may be that the camera itself relies on its projection matrix, rather than transform.
Could you share screenshots of your camera's full Inspector? I'll attempt a recreation.
Thank you Chris!
So based on what I gather, I need to add a 'Remember Transform' component on the
GameCamera2DDrag
game object and not on the 'Main Camera' one, is that right?I did that and I can see that the transform is stored in the save file but once I load the saved game, the transform doesn't get restored.
Here's the full inspector of the 2D drag game camera:
and here's the save file that shows that the transform of that camera is in fact stored.
My assumption is that because the 2D drag game camera is an 'attached' camera to the main camera, the main camera dictates its transform, that's why it cannot get explicitly set?
My project is really bare-bones now, just a plain 2D game project with just one scene and nothing else really. I can share any of the Settings from the Settings Manager if you want.
The other way around - GameCameras act as a reference point for the MainCamera. It's similar to Virtual Cameras and Cinemachine Brains, if your familiar with Unity's Cinemachine system.
I've recreated the issue. I suspect it'll be a case of relying on a dedicated Remember component, which deals specifically with this camera type. I'll look into this and report back shortly - thanks for flagging this.
Gotcha, yes I am aware of the Cinemachine system. Thank you for pointing that out!
No worries! It's not a super huge issue right now -for me at least- but it would have been great if the camera position was remembered once you load the game, so that it would resume at the same exact point it was saved (just like the rest of the game cameras already do).
Thank you for your fast and great support!
OK, I've looked into this. Indeed, it'll need a dedicated Remember component of its own - however, it also requires a bit of tweaking to the GameCamera2DDrag to expose the data that needs saving.
I'll make these changes and provide a "Remember GameCamera 2D Drag" component in the next release - thanks for raising the issue.
Thank you Chris! Keep up the great work!
Just commenting here to let you know that after upgrading to version 1.78.0 and adding the 'Remember GameCamera 2D Drag' component, everything seems to be working just fine! Thanks again Chris!