Hey, here comes a small update about our game camera.
As our game is 3D top-down and has a camera with a fixed pov, it’s more or less inevitable that the player character sooner or later will get obstructed by some other object in the world. The player might wander behind a wall, tree or whatever other thing that exists in the level, hiding the player character and creating frustration and less fun.
One solution for this is to do what many games do and move the camera past, or in front if you will, the obstructing object, moving it closer to the player. Obviously a bad solution for a top down game as the cameras distance to the obstructing object is so much further than the distance between the object and the player, making the correction of the camera very drastic and abrupt.
So the solution we use is the one most 3D top-down games use, which of course is to make the obstructing mesh transparent, in our case just adjusting the alpha channel of the relevant object. Below is an example of the effect in use.
The above result is achieved by sending out an raycast from the camera, which at hit tells the relevant object to adjust its alpha channel. Simple enough, and I think this works pretty well for a fast implementation, although it has a few drawbacks. If you notice in the GIF above, manipulating the alpha channel of an object also adjusts the shadow strength, which makes no sense from the player’s perspective. This is fixable by doing transparency with shader code instead, among other solutions I’m sure.
Another problem is my use of the raycast. It stops at the first object it hits, and only “sees” that first object, potentially ignoring other layers. So if two or more objects are obstructing the player character from the player’s view, only the first object will get told to get transparent, resulting in not making anything better for the player. One fix for this is to always send out a follow up raycast as long as some valid object is hit with the first raycast, and keep doing it to no objects is found by the outgoing ray.
But as time is scarce with this project, as always, I’m not sure what I’ll have time to fix, but at least I know what to look out for in the future.
Next up for me is to keep working on AI and also to implement the player character. That’s it for this time, see you later.
0 comments