Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58431 Members - Latest Member: Bohdan_Zoshchenko

April 27, 2024, 06:40:46 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsThe Decision Engine (2D Platforming in 3D space)
Pages: [1]
Print
Author Topic: The Decision Engine (2D Platforming in 3D space)  (Read 9174 times)
Tattomoosa
Level 0
**

Making The Decision Engine


View Profile WWW
« on: May 11, 2018, 02:04:15 PM »

Most Recent GIF:



WIP Concept Art/Poster:



The Decision Engine is a 2D platformer in 3D space where you control a small robot trying to escape a monolithic factory under the watchful gaze of a powerful and ancient machine known only as “The I”. Unravel a dark history in vast locations and learn to bend the factory itself to your will.

Part 1 - "True" 2.5D
Part 2 - Initial Concept Art
Part 3 - Environmental Effects
Part 4 - Technical: 2D Control Along a Bezier Curve
« Last Edit: June 21, 2018, 01:17:03 PM by Tattomoosa » Logged

Tattomoosa
Level 0
**

Making The Decision Engine


View Profile WWW
« Reply #1 on: May 11, 2018, 02:11:07 PM »





Here's the initial prototype of the 2.5D system in Unity. It actually does currently support branching paths, but I never bothered to jump on any while I was capturing this   Durr...?

Basically, it works by defining a ‘forward’ vector based on the closest curve normal to the actor. The actor then has its own ‘forward’ vector, which is constantly being ‘pushed’ towards the curves ‘forward’ vector, by a ratio that depends on the distance between where those vectors are pointing. I was worried at first that this was a fairly fiddly way to do it, but it seems pretty robust. Most of the jittery movements in the demo are actually because the camera is going to be much more complex than the characters and needs a lot of work still.

I am currently using an asset called BGCurve for the splines, but it might be a bit overkill. The nature of a spinning camera in a platformer requires a fairly wide curve or else it gets a little bit funny, so I definitely at least have to put in some hard clamps on that. It may make more sense to have my own purpose build spline implementation, but I haven’t looked too far into that at this point.

Basic platforming and extremely basic non-player AI is implemented and both sorts of actors follow the curves quite successfully. I’ve stress-tested the system with roughly 150 actors and it holds up just fine, but my PC is also fairly beastly so I’m not sure I can use it as a benchmark.

Right now, I'm trying to decide where to go next. I'm considering polishing up the basics and releasing it as a paid asset to help fund the game, since there's actually nothing on the Asset Store like it, but I have stumbled on posts where people try with limited success to implement the same idea. The difficulty lies in how integrated actor movement is to the system, though. It would be tough to add other character actions without knowing how it works in it's current state... so I'm not sure how much sense it would make as an asset.

I think I need to polish up the curve editing at least, or else I'm going to be pulling my hair out trying to make real levels. The camera also needs a lot of work, and currently there are several collision edge-cases that aren't handled properly.
« Last Edit: May 11, 2018, 02:35:17 PM by Tattomoosa » Logged

drkr
Level 0
**


View Profile WWW
« Reply #2 on: May 11, 2018, 06:47:12 PM »

The platforming looks really solid, seems like it would be pretty fun to play around with.
Logged

turbo banana
Level 0
**



View Profile
« Reply #3 on: May 12, 2018, 03:24:29 AM »

Nice job!

I am working on a similar type of game and I was quite surprised how little information there was about curved path (I am using unreal) .
I ended up implemented my system in a almost the same way .

I think selling your system is a good idea .

Looking forward to see the next update .
Logged

and
Level 6
*



View Profile WWW
« Reply #4 on: June 07, 2018, 10:30:51 PM »

I understand nothing of what you said, or how I would even begin to go about building something like this. The video is really impressive though and immediately made me think 'oh damn I want to make a 2.5D game next!'

This is definitely the kind of thing I'd pay for.
Logged

Tattomoosa
Level 0
**

Making The Decision Engine


View Profile WWW
« Reply #5 on: June 08, 2018, 11:47:00 AM »

Thanks! Good to know that there is some real interest in it.

I've mostly taken a step back from the project to learn C# better and maybe get out a few small projects. I'm a web developer by trade but Unity's Javascript implementation is non-standard and that seems frustrating, not to mention confusing to bounce between real Javascript for work and psuedo-Javascript in Unity. Plus, Unity tutorials and code examples are almost always in C#. But the problem so far is that I've been using the tricks I'm familiar with in Javascript to write C# instead of learning about the more C#-y ways to accomplish the same things in a cleaner fashion.

Because of this approach, it would be a real pain for anyone else to try on bolt anything else to what I've got right now (even just a character with a different moveset). But it is improving little by little as I learn more about C# best practices and think about the cleanest ways to do things.

The camera is a bigger issue, though. The video doesn't show off how bad it can be in some of the worst edge cases. I think my current implementation is going to wind up in the trash altogether.

So work on the game continues even though I haven't added much in-game. It has the start of a story now, and a name, and some rough/WIP concept art:


Featured in the poster is the antagonist of the game, an artificial intelligence tentatively called "The I", and one of several monuments it's built of it's mother. She's looking a little too masculine right now, though. I'm struggling a bit with making her look more feminine without making her look too much more attractive.

I think having a lot of intricate, industrial machinery will play really nicely with big camera pans. Probably a lot of pipes and wires to really sell the depth. The colors will be more reigned in though, or else I'd go crazy trying to write shaders! I want to stick mostly with a very mechanical setting since I think that will be easier to model and texture. But I do like the big floating cubes in the tech demo, so I'm considering having some sections be more surreal or abstract - maybe "Digital" levels when you've hooked into some machinery, but that seems a little cliche.

My gameplay goal is to really utilize the 3D space even though you play in 2D. So things like projectiles coming from the background, platforms you can walk on that move & rotate in 3D space, shortcut paths perpendicular to the main ones, etc. I'd love for it to be a big and interconnected "Metroidvania" style world. But since the whole world is this great big factory, there's a lot of opportunity for moving pieces and environmental puzzles and having paths come back to each other in unexpected ways.

All of that is going to necessitate a pretty robust level editor, so hopefully building that out with the medium-term goal of selling the package as an asset works out in my favor by encouraging me to make good tools instead of settling for some garbage that's just enough to be usable. Smiley
« Last Edit: June 08, 2018, 12:40:37 PM by Tattomoosa » Logged

turbo banana
Level 0
**



View Profile
« Reply #6 on: June 11, 2018, 01:16:06 PM »

Glad to see you are still developing this project .

I like the artwork . It reminds me a bit of some of the crazy architecture/drawings seen in the manga 'Blame!' (from Tsutomu Nihei; thanks wikipedia) .
Logged

and
Level 6
*



View Profile WWW
« Reply #7 on: June 12, 2018, 06:50:16 AM »

I love the idea of it being set within a giant machine/factory and can totally imagine the views being amazing. Because it's in 2.5D you can have some really breath-taking reveals as you turn a corner, letting the backgrounds tell a lot of the story for you.

I also really liked the floating blocks, so a dream like digital stage sounds like a great idea Smiley
Logged

sidbarnhoorn
Level 3
***


View Profile WWW
« Reply #8 on: June 12, 2018, 08:54:07 AM »

This looks awesome! I love the poster/artwork and the gameplay. Looking forward to playing this sometime!
Logged

Siddhartha Barnhoorn
--------------------
Award winning composer

Composed music for the games Antichamber, Out There, The Stanley Parable, Planet Alpha...

Website:
http://www.sidbarnhoorn.com
Bandcamp:
https://siddharthabarnhoorn.bandcamp.com
Twitter:
https://twitter.com/SidBarnhoorn
Tattomoosa
Level 0
**

Making The Decision Engine


View Profile WWW
« Reply #9 on: June 20, 2018, 05:52:45 PM »

This looks awesome! I love the poster/artwork and the gameplay. Looking forward to playing this sometime!

Thank you! I loved your score in Antichamber! Just put on Structures of Light to help me write this post - enjoying it so far and thinking more of your work will have to make its way into my ambient programming playlist. Smiley

I like the artwork . It reminds me a bit of some of the crazy architecture/drawings seen in the manga 'Blame!' (from Tsutomu Nihei; thanks wikipedia) .

Thanks! I hadn't heard of 'Blame!' but it is looking like something I have to read... almost like a tech-style Silent Hill in it's aesthetic. Very cool!

I love the idea of it being set within a giant machine/factory and can totally imagine the views being amazing. Because it's in 2.5D you can have some really breath-taking reveals as you turn a corner, letting the backgrounds tell a lot of the story for you.

That's the plan! I'm super inspired by the environmental storytelling in Hollow Knight and Metroid - especially Fusion. Hollow Knight in particular is basically why I'm making a game at all - I'm a huge Zelda fan, yet Hollow Knight was probably my GOTY last year and it was made by only 3-ish people!

I'm also really inspired by Inside, which is going to get pretty obvious as I work on more environmental effects. Thankfully they have several incredible GDC talks about how they implemented and optimized their environmental effects. I haven't utilized any of their cooler tricks yet, but I do have fog and volumetric lights working:



Caught a nagging slope bug while recording. Haven't caught the cause of it yet, so please ignore that and the sloppy 'wall-hiding'. I'm not sure if an automated solution will do for hiding occluding geometry, I might have to trigger that manually since the game will loop around on itself. That awkward curved walkway is pretty nasty as well. I'm probably going to need to come up with a custom solution for making nice curved walkways.

This is still a test area, but I'm starting to feel out the vibe for the first location: The Data Center.

Here's a still because of that unfortunate GIF banding:



Visible in the gif is a draft of the Data Center's server farm. I want to make the lights multicolored and blinking but I'm unsure if I'm going to go the shader route or make each light a little plane for more direct control/ease-of-editing. What I have now is good enough for now, though, and I don't want to get too bogged down in details just yet. Does anyone have advice on what's better for this sort of thing?

I think up next I'm going to implement a rudimentary UI so I can make some things examine-able, and continue to refactor the sloppier parts of my character controller code.

Next time I'll probably talk about some of the other locations that I have planned and how they fit together.
« Last Edit: June 20, 2018, 07:01:11 PM by Tattomoosa » Logged

Nordanvinden
Level 2
**

Indie game developer from Stockholm Sweden


View Profile WWW
« Reply #10 on: June 21, 2018, 01:21:48 AM »

This looks really nice. Im looking forward to seeing some more progress Smiley An even more in depth tech talk about how the 2.5D system works would be very interesting!
Logged

Rarykos
Level 1
*



View Profile WWW
« Reply #11 on: June 21, 2018, 02:00:53 AM »

I love that atmosphere here on display, looks good! Shocked

That protagonist robot is quite cute, are you planning to go with that? The Brave Little Toaster :D

That concept art looks quite dark, what's the tone here? Looking at it, I'm thinking Amnesia, or The MAchine for Pigs etc. You know, I expect dark violence and horror... IS that the goal? Little NIghtmares kinda vibe?


Sorry for the typos, my hands are tired...
Logged

badru
Level 0
***



View Profile WWW
« Reply #12 on: June 21, 2018, 08:22:21 AM »

Yoo this looks lovely!!

Excellent work on the light/fog and also on the sweet sweet camera motion. The Playdead inspiration is clear, in a good way Smiley

RE: the blinking lights, I'd do it in a shader for cleanliness and performance reasons, but I really like writing shaders and tend to be overanxious about perf, haha. I'd write a shader that uses vertex color and blinks them on/off based on _Time, with the intention that they all be batched together with one material.
Logged

Tattomoosa
Level 0
**

Making The Decision Engine


View Profile WWW
« Reply #13 on: June 21, 2018, 12:45:32 PM »

Yoo this looks lovely!!

Excellent work on the light/fog and also on the sweet sweet camera motion. The Playdead inspiration is clear, in a good way Smiley

RE: the blinking lights, I'd do it in a shader for cleanliness and performance reasons, but I really like writing shaders and tend to be overanxious about perf, haha. I'd write a shader that uses vertex color and blinks them on/off based on _Time, with the intention that they all be batched together with one material.

Thank you! I want long draw distances and a lot of realtime lights so performance is a real consideration. I’m currently a bit intimidated by shaders, so it’s good to hear that there are people that enjoy writing them… Hopefully I find that I'm one of those people because they seem super useful. Smiley

I love that atmosphere here on display, looks good! Shocked

That protagonist robot is quite cute, are you planning to go with that? The Brave Little Toaster :D

That concept art looks quite dark, what's the tone here? Looking at it, I'm thinking Amnesia, or The MAchine for Pigs etc. You know, I expect dark violence and horror... IS that the goal? Little NIghtmares kinda vibe?

Thanks! Glad you think it's cute! I am planning on going with that and why will be a bit more obvious when I manage to get another core feature implemented. I'm going to keep that secret for now, though. Smiley

Brave Little Toaster might be a decent comparison, I recall that movie being fairly dark...

My concept art might be selling 'horror' a little too hard, but we'll see how things develop. The story I have in mind is dark, but not really in an overtly violent or horrific way. I'm targeting a tone like Hollow Knight or Metroid. The little bot you control is not helpless.

This looks really nice. Im looking forward to seeing some more progress Smiley An even more in depth tech talk about how the 2.5D system works would be very interesting!

Thanks! It's actually a good time to talk about it in more detail - I'm currently refactoring my character controller to make it more extensible, which entails remembering and/or re-learning how it all works anyway...  Cheesy

So here we go:



This is a technical post
2D Control Along a Bezier Curve

“2D control along a bezier curve” is the most accurate short phrase I’m able to come up with to describe the implementation. Basically, I wrote a 2D character controller and I ‘spin it’ based on the tangent of the closest point along the curve. Less basically, the whole process looks like this:

NOTE: Unity uses the Y axis as the up axis

Step 1: Make a Bezier Curve

I'm using the excellent/free/MIT-licensed BGCurve for creating splines. If you want more info on splines themselves, there’s this excellent tutorial from Catlike Coding. That site is worth a look even if you don’t care about splines, it’s a treasure trove of great Unity information - mostly how to accomplish things that need some amount of fairly intimidating math.



So I’m technically using Splines (3D bezier curves) but most of the time I just throw away the Y axis information.

Step 2: Make 2D Character Controller

My character controller setup is getting more complicated for modularity reasons, and I may go into that at some point, but the gist of it is that most of the character controller ‘thinks’ of the world in 2D. I’m using Vector3.forward as ‘right’, Vector3.back as ‘left’ and Vector3.up/down for up/down respectively, but I could very well be using a Vector2 instead.

Then I store this vector as the character’s “Goal Position”, though I'm just calling it 'velocity' in the script.

This is before checking collision, too. It’s basically just “This character is trying to move forward or jump or take this action” at this point.

Step 3: Determine what direction 'forward' is

So then we need to determine how to rotate that “Goal Position” vector so that ‘forward’ is the closest point along the bezier curve. Note that I don’t mean the nearest ‘control point’. BGCurve allows you to determine the granularity of a curve, and how many points are plotted between each control point. I think I’m using whatever the default is.

BGCurve does all the heavy lifting here, and I went ahead and posted a GitHub gist of the class I use to streamline this. Really, this class should just extend BGCurve and do it all that way, but I lost BGCurve's GUI when I did that. I'm sure that's an easy fix but I didn't want to mess with it at the time.

Step 4: Course Correction

I wouldn't need this step if I had some way of ensuring the character was always precisely on the path - like if our 'forward' calculation had a really high resolution and we always placed characters perfectly on the path. This isn't really feasible, so I just apply some course correction instead.

You'll notice if you looked at the gist that I'm saving the point on the curve while calculating 'forward'. So I make a vector between that and the character's position, throw away the 'Y' axis, and Lerp between that and 'forward' based on how far off course (the distance to that point) the character is.

See this image, where the white line is little bot's forward and backward directions, and the red line is the correction vector.



Course correction at work:



This would be simpler if I chose to walk RIGHT instead of LEFT... That purple line is actually the OPPOSITE of the correction vector, due to moving left being negative and some messy internals that will be fixed in the refactor.

You might notice I'm actually doing all of these calculations based on positions on the ground. This is so that paths can cross over themselves without your character latching on to a path above them when they jump:


(The upper path is much closer to the character than it looks in this gif...)

I actually do this by simply replacing the character's Y position with the Y position they had last time they were grounded in all relevant calculations.

Step 5: Rotate the Character

Now that I know which way forward is, I could do some fancy vector math to determine which way to march... or I could just rotate the character to look in that direction, then manipulate their movement in local space! Both would work, but the second way requires less mental overhead, so that's what I do.

Step 6: Check Collisions

I check environment collisions in local 'pseudo-2D' space using raycasting (from the 3D physics engine) instead of Colliders for those sweet fake physics that act like you expect a 2D platformer to act. I'm doing this in a fairly standard way for a 2D character, I think. I based my implementation on a tutorial series by Sebastian Lague. (EDIT: I had it linked but it embedded the video instead and I don't want that so you'll have to search, sorry!) I might have gotten my jump implementation from somewhere else though - it lets me plug in a "Time To Jump Apex" and a "Jump Height" and magically calculates the needed velocity. I'm adding extra gravity on descent, too, that's a trick stolen from Mario.

You can see the collision raycasts visualized here, where cyan means no collision and red means a collision. I'm also using red for the line down to the floor for some reason, and I don't know what that cyan line is supposed to be showing Cheesy I'm running a lot of raycasts for the player character. I think that this is due to slopes, but maybe I could get away with less.



Then, again in fairly standard 2D character controller style, anywhere where there is a collision detected I move the "Goal Position" outside of the colliding object.

Step 6: Place The Character

Now that we know where the character should be this frame, we finally apply the position to the character and we're done.

Other Considerations

I'm calculating slopes as if they were 2D slopes so if you have questions about that check out Sebastion Lague's tutorial I posted above. I had a bit of trouble rotating the character to affix to the slope, and I think I just brute forced that by trying a bunch of random Quaternion math until I stumbled into something that worked.

To handle path changing, I simply place Colliders (with 'isTrigger' turned on) on the same object as the curve, and those tell any object that can change curves to do so upon entering the collider.

I'm moving around a lot of this code, but the refactor will follow basically these same steps with a new modular pattern where I can give and take various behaviors.

As just a piece of general advice, whenever you're calculating stuff in 3D - DRAW IT!! I always set up some 'logging' booleans so I can turn my debugging drawing on and off easily, and leave it in even when I think things are working so if I run into a weird edge case I can turn it back on.

End of technical post


Whoa that took me nearly 3 hours to write out and edit instead of the 1 I had planned. Time to get back to the refactor before I've lost my whole day to forum posts! Smiley

(EDIT: Then I spent another 15 minutes making random edits! What am I doing!)

I hope the tech update was useful. I may still release it all as an asset down the line, but it depends on how clean the refactor is and how willing I am to write documentation...  Shrug
« Last Edit: June 21, 2018, 12:56:44 PM by Tattomoosa » Logged

turbo banana
Level 0
**



View Profile
« Reply #14 on: June 21, 2018, 01:48:40 PM »

very nice write up ! I am not sure if this would be an issue for you but I faced a problem with step 5 .
It would work fine but if I was trying to move my character in one direction but the character had a force applied to it that pushed it in the opposite direction it would pull away from the curve as it was still trying to rotate toward it despite moving in the opposite direction .



I don't know if my explanation is very clear or even relevant to you but I discovered this issue quite late when I started playing with explosions and moving platforms so I thought it could maybe help . Smiley

« Last Edit: June 21, 2018, 01:56:57 PM by turbo banana » Logged

meshpotato
Level 0
**


View Profile
« Reply #15 on: August 12, 2019, 06:40:05 AM »

This looks really cool!
How do you switch between the different curves and make sure that the right one is followed when jumping between multiple levels?

Are you just using triggers with box colliders to find the current curve to follow?
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic