Game
Project Luna
7 years ago

Camera update, transparency functionality


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.

5d0a824e91838.gif

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

Loading...

Next up

Emanuel Holm – Level Designer(blog 1#)

The final days of working with the project

Emanuel Holm - Level designer (Blog 2#)

My thoughts of being a level designer

Path of Kami: The Evolution of the Lore

The whole squad is here!

Interested? Follow me!

Finished work on the emotions of a new character for the tank universe

Made my first ever animation.

Auto-chess meets Clash Royale in an intense strategic battle. Outsmart your opponent, hide your play and crush their armies! Empire Builder just got another major update, check it out! https://gamejolt.com/games/EmpireBuilder/558901

2d lighting experiment