After several setbacks, I've finally completed another new game! You can play it here:
https://dgalga.itch.io/ghost-and-hostage
Brief gameplay video:
The basis for this game idea is the cloaking and anti-terrorist/government operations featured in the Ghost in the Shell series. (Video omitted for copyright content, but check out the series if you're interested!)
There's far too many concepts in the above video (remote hacking and possession, coordinated defensive action, coordinated team action, etc) for me to cover in one 3 hour prototype at my current skill level. So, I also focused on what I can recall enjoying most from my time playing an old multiplayer mod called NEOTOKYO:
NEOTOKYO also focuses heavily on squad tactics, but teamkills (your teammates killing you or you accidentally killing your teammates) are a thing, so I actually spent most of my time in the game going off on my own. It was the feeling of stealthily lone-gunning an area that I was hoping to recapture with my new prototype.
I don't think I was successful. As you can probably tell in the gameplay video of Ghost and Hostage, it's easily possible to lead all of the enemies in the level away from the hostage and the main path. This is because the enemies can respond to your gunshots, but don't patrol or return to their original positions. I believe that a modicum of coordination or independent action on the part of the enemies would make the game far more interesting and challenging. Unfortunately, I ran out of time to test this.
The most important aspect, to me, is the enemy pathfinding. I borrowed a solution from the following site and adapted it a bit:
https://www.davidepesce.com/2019/11/19/godot-tutorial-how-to-use-navigation2d-for-pathfinding/
After that came the invisibility. I did find this
https://gamedevserj.github.io/godot-invisibility-shader-tutorial.html
However, I couldn't get the same shifting/murky effect. I did get as far as making my player object disappear, so I mixed in some code from this shader on outlining an object:
https://godotshaders.com/shader/2d-outline-stroke/
and, mixed in a little from the Action RPG tutorial series by HeartBeast to arrive at this shader code:
shader_type canvas_item;
//variable to allow disabling and re-enabling shader:
uniform bool active = false;
uniform vec4 line_color : hint_color = vec4(1);
uniform float line_thickness : hint_range(0, 10) = 1.0;
void fragment()
{//need previous color to revert to!
vec4 previous_color = texture(TEXTURE,UV);
vec4 screenTexture = texture(SCREEN_TEXTURE, SCREEN_UV);
COLOR = screenTexture;
vec2 size = TEXTURE_PIXEL_SIZE * line_thickness;
float outline = texture(TEXTURE, UV + vec2(-size.x, 0)).a;
outline += texture(TEXTURE, UV + vec2(0, size.y)).a;
outline += texture(TEXTURE, UV + vec2(size.x, 0)).a;
outline += texture(TEXTURE, UV + vec2(0, -size.y)).a;
outline += texture(TEXTURE, UV + vec2(-size.x, size.y)).a;
outline += texture(TEXTURE, UV + vec2(size.x, size.y)).a;
outline += texture(TEXTURE, UV + vec2(-size.x, -size.y)).a;
outline += texture(TEXTURE, UV + vec2(size.x, -size.y)).a;
outline = min(outline, 1.0);
if(active)
{
vec4 color = texture(TEXTURE, UV);
COLOR = mix(screenTexture, line_color, outline - color.a);
}
else
{
COLOR = previous_color;
}
}
I don't fully understand shaders yet. I think I get the basics of what this code is doing, but I don't trust myself to fully explain it yet. Basically, this shader is using the color of the background to overwrite the color of my sprite, effectively hiding it, while drawing a line around the outline of the sprite. I think.
Finally, there was the issue of making sure the enemies cannot see the player through objects. This was a pickle, because I initially started out using a raycast2D scanning thing that looked like a Cylon scanning the environment.
After fiddling with this scanning idea for far too long, I gave up and adapted this solution to fit my needs instead:
Ghost and Hostage is lacking alot, but it's better than the project I failed to finish for week 2. I'm a little disappointed with myself that I failed to put out 4 games in 4 weeks, so I'm going to do my best to ensure I get 3 uninterrupted hours to finish something playable this week. Expect something next weekend!
No comments:
Post a Comment