• General Chat
  • Scrolling Prerendered BG / Camera Environ. Aligned with 3DSpace

I am going crazy trying to understand how this works.

Static prerendered backgrounds are simple enough but I am absolutely lost at trying to get a 2D Camera to translate properly so that the 2D image aligns with the collision shapes in 3D.

I need some input on this problem.

Youtube any Final Fantasy 9 video, excluding the static backgrounds, when a tracking camera is used you can see that: -the 2D background increments Y coordinates relative to the Z and Y of the character being tracked by the camera.
-the 2D background increments X coordinates relative to the tracked character's X position in 3D space.

If the 2D background's height is greater than the screen height, Y increments to a limit, which I assume would be designated with Godot's 2D Camera Limit parameters. Likewise with 3D x position and screen width.

BG Texture is drawn as a sprite and the camera sets it as its environment You need a 2D cam and a 3D cam Screen dimensions BG Texture size

I am getting really wierd coordinates when I unproject_position of the character that is being tracked, I am not sure why they aren't within the range of the screen dimensions, but they aren't, and one's negative

Not even sure why I use the unproject_position of the character other than developing some connection between 2D and 3D space

Maybe it is required to know this formula but i dont know why: distance_to_screen_edge_in_3d = tan(fov2/) * z

Anyway, I tried looking at a some stuff on GitHUB written for Ogre like the page below, but I couldn't really get anything from it other than generally recognizing some functions, but I just don't see how they would go together

https://github.com/q-gears/q-gears/blob/3da522b996f09e81c148b25bd8cd022d8db761ef/QGearsMain/src/core/Background2D.cpp

**What I find really confusing is that in videos like FF9, the Camera is clearly in perspective mode because the character scales with space, but that the background stays aligned with the collision shapes from whatever angle the camera is tracking the character.

So one thing I am thinking about is that it is easy to have the 2D background move by some vector, but if you have just a line that says 'translate background (vector2(magic_number_x,magic_number_y)), it will translate even if your character is running into a wall.

So my first thought seems like a crude and incorrect idea, but I immediately think to draw a ray from the character which checks to see if something is in front of it, and if there is nothing in front of it, it translates the background. It would have to be a very short ray of course. But again, I think that is just a crude way of figuring it out and I am not going to try it, yet at least.

Think I am realizing some more stuff about how it works. It is much more of rules about panning the camera than anything else, as I see it now. Even though I knew it was a fixed angle, I initially thought that the angle of the camera was changing more than I think it does now. There is a condition that if the character is a certain distance from the camera, the 3D camera will do rotation but I haven't figured what that condition is.

After playing a bit of a game I think the following occurs:

If the Y of the character increases, the Y of the 3D camera also increases. Likewise with decreasing. In both cases, the Y of the 3D camera will stop incrementing if the Y of the 2D camera has reached its scroll limit. This always happens in the case that the dimensions extend beyond the screen limit. I still don't know how to calculate how much to scroll the 2D camera.

I am making a guess when I say that, I think that if there is a BG Texture with width and height beyond that of the screen dimensions, then the 3D camera will increment its Z with that of the character, but only then. Otherwise it does not increment it's Z at all. This may be wrong, I'll have to think it over more.

Another thought I had which didn't end up working, but maybe it's related to sucesss:

The easy idea would just be, move the 3D camera with the avatar, and move the 2D camera according to where the player's projected position is.

Of course, the projected position is always going to be the same if the 3D camera is moving with the avatar, and so the 2D cam would never change its position.

This reminds me that one thing that is really screwing me up is that when I translate or move_local_x of the Camera2D there is a long period of delay in between when it appears to be moving. I assumed this was 'drag' but I've set the drag to 0, tried disabling it, changing the scale, and there is always this period of delay, which I assume is drag. Don't know how to get around that.