Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

leper khan posted:

Easy mode is to use a rectangular prism or a cylinder.

Yeah, honestly I'd recommend this approach. Quads can work, absolutely, but they're kind of fiddly, the illusion isn't completely foolproof, and nobody should care about the difference between 4 tris and, like, 50.

This is my "shell" model:



I make it spin axially during flight; the two jagged tails then look kind of like a fire trail behind the shell. It works surprisingly well, given that the material is unlit so you can't really make out any details. For a laser blast you may want something more regular in shape.

Adbot
ADBOT LOVES YOU

dizzywhip
Dec 23, 2005

KillHour posted:

If you only want one bone to affect the vertex, wouldn't you just set the bone weight to 1?

Well the idea was to set it up so that the bone would affect some vertices more than others to get a stretching effect when it moved, so I had some weights set to 1 and some less than one.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

TooMuchAbstraction posted:

Quads can work, absolutely, but they're kind of fiddly, the illusion isn't completely foolproof, and nobody should care about the difference between 4 tris and, like, 50.

I should have mentioned that my target hardware is the Voodoo2.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Can you use a sprite that always faces the camera instead of your 3d rendering pipeline? (This is what Doom did for enemies and pickups).

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Jabor posted:

Can you use a sprite that always faces the camera instead of your 3d rendering pipeline? (This is what Doom did for enemies and pickups).

Billboards are a little sketchy for projectiles like this since you want to be able to indicate the projectile's orientation with its shape. A laser blast looks different if it's traveling almost entirely away from you vs. if it's traversing across your field of view at the same visual distance. You could maybe fake it by skewing/stretching the quad but that sounds like a lot of work to me.

KillHour
Oct 28, 2007


You'd achieve the same effect by using a single quad but only allowing the billboarding to rotate the quad along the forward axis. This would look fine in every situation except where the projectile is headed nearly straight at or away from the camera. You could partially solve this by having another quad with a circle sprite and true billboarding that is at the leading edge of the projectile.

Basically, you have a circle at the "front" of the projectile that is a small circle and always faces directly at the camera, then a second "trail" sprite that follows the circle and is pointed in the direction of travel, but also rotates around that axis to "face" the camera similar to billboarding for trees, where you don't want the tree to lie down sideways when you look up.

You'd have to play with transparency and blending modes so the two sprites look like they make up a single object instead of two.

KillHour
Oct 28, 2007


Quick and dirty:



This is a sphere of projectiles. Each is made up of two sprites.

This sprite is just scaled and faces the camera:


This sprite is stretched out and rotated along the direction of travel:

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

dizzywhip posted:

Well the idea was to set it up so that the bone would affect some vertices more than others to get a stretching effect when it moved, so I had some weights set to 1 and some less than one.

But what's the *other* influence that it cares about? Let's say you want very little stretching, so you assign a bone weight of 0.01. Where does it take most of its influence from? It has to have two bones to interpolate between.

dizzywhip
Dec 23, 2005

Suspicious Dish posted:

But what's the *other* influence that it cares about? Let's say you want very little stretching, so you assign a bone weight of 0.01. Where does it take most of its influence from? It has to have two bones to interpolate between.

Totally, my mental model about how it worked was wrong. In my head, the remaining influence would come from the vertex's default / bind position.

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Tip posted:

I finally announced my game! Spent the last two weeks just putting together graphics and copy. :gonk:

Anyways, it's called Rhyme Storm, and it's a freestyle rapping rhythm game! I've worked on it since the beginning of 2018 with another goon and a bunch of hip hop producers and I'm super proud of it! I don't think there's any other games like it.

I'd love to get feedback from you guys on it, here's our steam page:
https://store.steampowered.com/app/1250350/Rhyme_Storm/
Website:
https://www.rhymestorm.com

Trailer:

https://www.youtube.com/watch?v=Ce2T7M9xhzY


And some screenshots:











if you can figure out how to market this thing so that hip-hop heads know about it, i think you could have a hit. i could see kids sitting around with their friends trying to one-up each other as they try to be battle rappers :3:

might be cool for all the short video apps that are around these days too

perc2
May 16, 2020

Can anyone reccomend a book on graph algorithms, particularly w/r/t generating random graphs? I've been brainstorming some ideas for generating interconnected dungeon rooms ala Darkest Dungeon, and also towns connected by roads, but all these annoying edge cases keep coming up in my mind, particularly ensuring nodes are reachable, etc and I could do with some inspiration

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
generate a random graph, and remove any edges that don't meet your constraints

no, really. that's how most of them work

FuzzySlippers
Feb 6, 2009

Most commercial games use hilariously simple generation

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

perc2 posted:

Can anyone reccomend a book on graph algorithms, particularly w/r/t generating random graphs? I've been brainstorming some ideas for generating interconnected dungeon rooms ala Darkest Dungeon, and also towns connected by roads, but all these annoying edge cases keep coming up in my mind, particularly ensuring nodes are reachable, etc and I could do with some inspiration

Check out the talk by the guy who made unexplored https://www.youtube.com/watch?v=_wvkTT-6P3Q he has some longer videos and i think an interview on roguelike radio

Also look into L-systems and branch out from there

The other posters are right about not worrying too much about edge cases. If you hit something bad, you either try again or back up farther and try again. In the longer talk from the unexplored guy iirc there are 2 or 3 places where the algorithm starts over one or more steps earlier in the algorithm if it isn't working out. It's only bad if the edge cases are happening often, and you can have quite a few bad runs on a modern computer if it's just during a generation phase and not realtime. You still probably want a breaker that trips after too many tries or too much time and starts completely over, so you can be graceful about pathological cases.

taqueso fucked around with this message at 04:05 on Jun 18, 2020

abraham linksys
Sep 6, 2010

:darksouls:

KillHour posted:

I'm not sure what Godot has for built-in physics, but I'd strongly consider a heightmap based terrain system built from the spline data.

just wanted to say that while I've been very distracted by [gestures at state of world] and have been away from game dev for a bit, I just started playing Descenders on Xbox Game Pass on a lark, and it's really clearly this! they generate a spline for a track and then build a whole terrain around it, it's really impressive. if I end up not doing a "rainbow road" style game, and instead do something with a track built into a terrain, I think I'll give this a go...

Godot doesn't appear to have much at all built in for something like this, unfortunately. I'm thinking about switching to Unity so I can try some more "off the shelf" collision options, since I am still struggling with implementing collisions with the spline shape, but that seems like a big switch just to get collisions going like I want them.

abraham linksys fucked around with this message at 07:51 on Jun 20, 2020

xzzy
Mar 5, 2009

I can't stop laughing at how bad networking for Unity is. It's like they got to the point of admitting that multiplayer games are cool and should definitely be a feature, and just kinda left it at that.

And while Unity is spending a thousand years meditating about NetCode, a bunch of 3rd party solutions fill the void and trigger regular slapfights over which one is usable.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

xzzy posted:

I can't stop laughing at how bad networking for Unity is. It's like they got to the point of admitting that multiplayer games are cool and should definitely be a feature, and just kinda left it at that.

And while Unity is spending a thousand years meditating about NetCode, a bunch of 3rd party solutions fill the void and trigger regular slapfights over which one is usable.
The problem is there is no really good solution. Some games want a third-party server controlling everything, some games want one of the players to be the server, some want to be peer-to-peer, some want to transmit state, some want to transmit only timestamped changes to state, some want to transmit only timestamped *inputs* that provoke changes to state... Each of the options has advantages and disadvantages, so you can't really make a "one networking solution" that isn't poo poo for somebody.

more falafel please
Feb 26, 2005

forums poster

roomforthetuna posted:

The problem is there is no really good solution. Some games want a third-party server controlling everything, some games want one of the players to be the server, some want to be peer-to-peer, some want to transmit state, some want to transmit only timestamped changes to state, some want to transmit only timestamped *inputs* that provoke changes to state... Each of the options has advantages and disadvantages, so you can't really make a "one networking solution" that isn't poo poo for somebody.

It's definitely not one-size-fits-all but UE4's replication system can handle all of the situations you mentioned. It's not a great option for lockstep games, but that's a pretty niche category (and the networking side of lockstep games isn't the hard part, it's making your simulation 100% deterministic with the same inputs, and handling rollback if you're doing rollback).

abraham linksys
Sep 6, 2010

:darksouls:
i haven't looked at unity's networking docs in a few years, is there any indication their forever-in-development next-gen netcode is gonna be ECS-first? sorta makes sense to me you can do networking "cheaper" with state and systems separated, though in practice you need so much more fine-grained control than just "make this component always match the server's"

xzzy
Mar 5, 2009

abraham linksys posted:

i haven't looked at unity's networking docs in a few years, is there any indication their forever-in-development next-gen netcode is gonna be ECS-first? sorta makes sense to me you can do networking "cheaper" with state and systems separated, though in practice you need so much more fine-grained control than just "make this component always match the server's"

Yes, and they have a note about it in their documentation of the new stack:

https://docs.unity3d.com/Packages/com.unity.netcode@0.0/manual/index.html

This stuff is all live and available for use but it's got an alpha badge on it so they're cautious to recommend not using it in production. It's all built around DOTS so anyone wanting to play needs to prepare to spend a couple afternoons wrapping their head around that workflow.

xzzy fucked around with this message at 20:18 on Jun 21, 2020

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I just tried to make some code in my Unity project async but it hooked into a UnityAction. Is there any standard square-peg-round-hole hackery to make that work? I might just have an overall better method that I think I can do without async but I'll probably run into this again.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Rocko Bonaparte posted:

I just tried to make some code in my Unity project async but it hooked into a UnityAction. Is there any standard square-peg-round-hole hackery to make that work? I might just have an overall better method that I think I can do without async but I'll probably run into this again.

await a task on the UnitySynchronizationContext that does your main thread things

more falafel please
Feb 26, 2005

forums poster

Just want to vent about a certain C#-based engine that supposedly supports a certain mobile-like console platform but implements the C# file operations by assuming that any file path you specify should be under the "Rom:/" mountpoint and will prepend it if the path doesn't start with "Rom:/", meaning that if you want to read or write ANY FILES NOT INCLUDED IN YOUR PACKAGE then you need to write a separate native library that implements any file operations you might want to do and rewrite all your code that uses File.* or Directory.* to use your poo poo instead. Oh also this platform crashes if you attempt to access a file that doesn't exist, you cannot handle the exception

xzzy
Mar 5, 2009

Quick unity ECS question: are subscenes the One True Way for building out a map? I've spent a couple weeks getting myself going with DOTS and this is one thing I haven't had much luck finding discussion or documentation on.

To clarify, a lot of the existing documentation explains that the 'Convert to Entity' component you can add to gameobjects is totally fine and works great (but isn't the most efficient as it's a runtime conversion). However, when I do this with the latest version of Unity, none of my game assets are visible in play mode (traditional gameobjects are fine). When I move all the geometry to a subscene however it works great.

I guess since I've figured out a method that works the question is kind of irrelevant in terms of make software that works, but I'm curious on the background.

cultureulterior
Jan 27, 2004

xzzy posted:

Quick unity ECS question: are subscenes the One True Way for building out a map? I've spent a couple weeks getting myself going with DOTS and this is one thing I haven't had much luck finding discussion or documentation on.

To clarify, a lot of the existing documentation explains that the 'Convert to Entity' component you can add to gameobjects is totally fine and works great (but isn't the most efficient as it's a runtime conversion). However, when I do this with the latest version of Unity, none of my game assets are visible in play mode

Is your hybrid renderer set up correctly? Which Unity version?

Raenir Salazar
Nov 5, 2010

College Slice
Maybe this problem/question is worth its own thread, but how do I go about writing a VERY basic compute shader in Unity3D that utilizes the real time ray tracing capability of RTX series nvidia cards?

I found this blog here which is great, for writing a basic ray tracing compute shader in Unity3D; but as far as I know, this doesn't use the capability, and also as far as I know a RTX card won't just automatically kick in just because there's ray tracing happening.

I opened up the HDRP+DXR start up project here from the documentation but it's still fairly intimidating, especially in comparison to the the blog linked above.

Basically how do I go about making the absolutely most bare bones Unity3D project and compute shader (or is it that new "raytracing" shader?) that will use the hardware capabilities offered by the RTX2080?

I basically just want to play with the shader and colouring basic primitive shapes and don't want to mess with an existing scene.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
You need DXR 1.1 and Inline Raytracing to use Raytracing from a Compute Shader. Otherwise, you're stuck with the dedicated ray-tracing pipelines, and I don't think Unity has support for them. But, I don't know if Unity's shader pipeline supports DXIL and DXR 1.1, since it needs to use the newest DXC versions.

See here for the shader APIs that you need to use: https://github.com/microsoft/DirectX-Specs/blob/master/d3d/Raytracing.md#inline-raytracing

Raenir Salazar
Nov 5, 2010

College Slice

Suspicious Dish posted:

You need DXR 1.1 and Inline Raytracing to use Raytracing from a Compute Shader. Otherwise, you're stuck with the dedicated ray-tracing pipelines, and I don't think Unity has support for them. But, I don't know if Unity's shader pipeline supports DXIL and DXR 1.1, since it needs to use the newest DXC versions.

See here for the shader APIs that you need to use: https://github.com/microsoft/DirectX-Specs/blob/master/d3d/Raytracing.md#inline-raytracing

Yeah unfortunately I wasn't able to figure it out from this, but fortunately a kind soul at the Unity forums provided me a working demo scene with the DXR 1.0 raytracing shaders doing 100% of the rendering in the Game view (when in play mode).

Mr Shiny Pants
Nov 12, 2012
Hey guys,

Any of you have any pointers on creating big smoke clouds that look good? I have some smoke particle systems that look good but don't actually scale. I really don't know how to start creating these, I don't mind buying a Unity asset if it is good.

I also need it for some big explosions.

Something that could simulate this: https://www.youtube.com/watch?v=IgCFP8FSerI

Edit: Well what do you know, seems like Unity has something for this: https://www.youtube.com/watch?v=R6D1b7zZHHA

Mind you, if anyone has some good advice, please do.

Mr Shiny Pants fucked around with this message at 19:33 on Jul 10, 2020

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
I implemented my own particle system to do this once (Too bad I never finished the game!):

HappyHippo posted:

Gif quality isn't the best but I've been working on a particle system for explosions for my RTS:



Higher quality gfycat video

You can try it here if you'd like: http://www.mseymour.ca/particle/particle.html click to make an explosion, right click to make a bigger one.

But you're probably better off not implementing it yourself

Enchanted Hat
Aug 18, 2013

Defeated in Diplomacy under suspicious circumstances

HappyHippo posted:

I implemented my own particle system to do this once (Too bad I never finished the game!):


You can try it here if you'd like: http://www.mseymour.ca/particle/particle.html click to make an explosion, right click to make a bigger one.

But you're probably better off not implementing it yourself

These are amazing!

Mr Shiny Pants
Nov 12, 2012

HappyHippo posted:

I implemented my own particle system to do this once (Too bad I never finished the game!):


You can try it here if you'd like: http://www.mseymour.ca/particle/particle.html click to make an explosion, right click to make a bigger one.

But you're probably better off not implementing it yourself

drat, these are better than the results I was getting inside Unity. :)

I wasn't planning on writing my own system, all other stuff is hard enough as it is.

fart barterer
Aug 24, 2006


David Byrne - Like Humans Do (Radio Edit).mp3
I've gotten a bit of an art style + some meshes down for a 2.5d game, including a lot of wall and floor tiles. It's the sort of game that is essentially tile based, but in a Unity 3D HDRP project, for fancy grafx and all.

I'm pretty handy with C# and I've been writing some toolbar scripts for Unity to help me along. However, I'm trying to leverage Unity Editor GUI scripting to make a nice 2.5 tile editor, and I'm hitting a wall trying to figure out the best way to do it. I could store what tiles go where in a huge flat array for an entire scene and generate the geometry at run time, but I want to be able to bake lighting as well as preview the final result as accurately as possible.

Ideally, I'd have a Room object with a Floor object with a MonoBehavior that, when the floor is selected, lets me select tiles in a new tool window and draw those tiles onto a grid. Those tiles would be static GameObjects with a MeshRenderer with a little quad with the right UVs for the tile in the atlas. However, I'm having hard time figuring out the conventional way to:
  • Create static child GameObjects based on Editor GUI / Monobehavior scripts.
  • Persist references to these static objects, so that drawing in the same spot will "replace" the old tile. I also wouldn't want more GameObjects being generated each time I load into the Scene. (I'm not sure which fields in a Monobehavior are persisted when the scene is saved, or if it does a deep copy serializing GameObjects stored in fields. I should test this..)
  • If I decide that a Floor belongs to a specific lighting (or other) layer, I can expose that as an appropriately named field on the Floor and have that selection cascade down to all child GameObjects. This same concept would apply to a lot of other shared properties.

I'd started using a texture to store which UVs to draw where in a larger mesh, as suggested in this neat blog post, but it'd be fairly restricting and would require me to store every tile in all four rotations in each (diffuse, bump, specular) texture atlas, so it'd be a pain in the rear end to make new art.

Anyone have experience with the general concept of streamlining static GameObject creation in a Scene? Am I overthinking this? If I have to awkardly snap and rotate thousands of Gameobjects to the grid this just won't be worth it.

e: After sleeping on it I'm realizing this is a convoluted example, and one with shader-based workarounds. A better example would be drawing a castle wall on a grid in the editor, and having a parent MonoBehavior dynamically set the end of the wall as a "cap", or draw a corner mesh for intersections of one or more wall lines. That sort of partially programmatic managing of static GameObjects.

fart barterer fucked around with this message at 14:23 on Jul 16, 2020

Sex Tragedy
Jan 28, 2007

father of three with an extra large butt
Anyone here know how to spawn a windows 10 window from unity. Like a separate window with a simple button GUI. Thanks.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Sex Tragedy posted:

Anyone here know how to spawn a windows 10 window from unity. Like a separate window with a simple button GUI. Thanks.

Process.Start?

Mr Shiny Pants
Nov 12, 2012

Sex Tragedy posted:

Anyone here know how to spawn a windows 10 window from unity. Like a separate window with a simple button GUI. Thanks.

Process.Start would work. Another way is to have the other application listen on a port and have Unity send over a command via the network.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I've implemented GOAP AI in my base building strategy game but it needs refactoring.

I'm trying to follow example projects like this one more closely, but no tutorials I've found really address what I'm trying to do. I'm not doing anything too complicated just the following task for example.

Build a thing I told the game to build on the map.

It requires delivery of a crate containing said object. Therefore my actor needs to go find a crate, bring it, then it can build the thing. So say the goal is "build_thing", I can have it check whether there's crates available of the given type for each thing waiting to be built. Then calculate the shortest route between every matching pair of things and crates.

But I still don't know which is the best choice because I don't know how far away the actor is from any of these crates. The actor could be anywhere, assuming that more actions could be queued before this one. So I need to process "get_crate", but crates containing what... there might be several.

So I can have it branch off for each available thing to build. Then the architecture starts to get complicated. Every example project I've found is simplistic and creates a dictionary of boolean values like "has_axe" but I need more than that, because "has_crate" but a crate containing something specific. And when the actor doesn't have a crate it needs to go and find a crate containing something specific.

This is just one example because maybe I'm storing the crate on a shelf. In this case it doesn't matter what's in the crate just go get the nearest one and put it away.

That would be more close to all of the example tutorials I've read. Another example tutorial was moving from one room to another when there's a door. In the example it was checking the state "door_closed" which is a nonsensical boolean state that doesn't seem to indicate which door it's supposed to be looking at. The example would be fine if there was only one door in the entire game.

Basically I'm struggling with examples of GOAP AI systems seeming to have no real world application.

Or I need a way for it to be a lot smarter.

Nolgthorn fucked around with this message at 23:13 on Aug 6, 2020

jizzy sillage
Aug 13, 2006

So first I'll ask, in your Action class, do you have a function that is run by the planner to check whether this Action is a viable one? From HappieCat's GOAP project:

code:
// check what actions can run using their checkProceduralPrecondition
HashSet<GOAPAction> usableActions = new HashSet<GOAPAction> ();
foreach (GOAPAction a in availableActions) 
  {
    if ( a.checkProceduralPrecondition(agent) )
      usableActions.Add(a);
  }
Writing this function for each of the Actions your agents may take is important. It turns an action from a dumb list of preconditions and effects into something that's a bit smarter. build_thing knows what it's building, right? It has a target, the thing it wants to build - a house, maybe:

code:
build_thing.checkProceduralPrecondition(agent)
{
  return resourceDepot.Find(target.requiredResource);
}
You can make States (the bools that are named and toggled on or off) smarter if you need to as well - or you can create and destroy them dynamically, along with their preconditions and effects. They don't need to just be bools. You could, every frame, sort through and add an Action to the Actor's list of available Actions for every type of thing you can build:

build_thing(house, wood)
build_thing(house, stone)
build_thing(pathway, dirt)

Then cull the list according to what resources exist on the map. You could even do this outside of the Actor, in a BuildingManagementDatabase or whatever, that tells all Actors of type Builder "Here are your available build options this frame. Request a plan from the planner."

Nolgthorn posted:

But I still don't know which is the best choice because I don't know how far away the actor is from any of these crates. The actor could be anywhere, assuming that more actions could be queued before this one.

Why can't you check this? The Actor should be aware of where it is, and where its target is. Are you not running your AI every frame? If you run it every frame, it would know if it or the target moved. If you don't want it to run every frame, you need error checking in the Action itself - "when I reached the wood pile, there was none left. I have to request a new plan". What happens when the Actor has its plan interrupted? What if its goal changes?

Nolgthorn posted:

In the example it was checking the state "door_closed" which is a nonsensical boolean state that doesn't seem to indicate which door it's supposed to be looking at.

When the Actor decides to move somewhere, it needs to call a pathfinding method to find a path there, right? Why not have your pathfinding method return a list of all closed doors in the path, and then store that in the Actor?

Hopefully this helps somewhat, GOAP isn't especially easy and I haven't yet finalised/finished my first implementation of it. Good luck!

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Thanks.

The solution I'm working on currently foregoes the concept of prerequisites and effects, which is foundational to GOAP. This is a big reason why I'm trying to refactor. I just haven't been able to wrap my head around how to model the system with more complex action requirements. Just saying I need a crate and there's an crate in the world doesn't cut it.

So in the action itself I have a function that checks prerequisites and returns an array of unfulfilled actions that need to be completed. In the "build_thing" action, it checks whether the actor is carrying what it needs and if not it creates a "get_crate" action and returns it in an array. This way while I'm building the plan I can run that and get back the actions that need to run first.

In that way I'm essentially doing what GOAP is supposed to be doing.

But I need to attempt to form plans for every blueprint type waiting to be constructed. If I have "shelf" and "stairs" blueprints in the world, that's effectively two separate goals, which are compared before choosing one.

I build out all possible plans from end to start. Then from the start I figure out what path finding is necessary. During this path finding step I'm essentially picking which actual objects in the scene are going to be interacted with. Lets say it figured out that the cheapest plan is to pick up the crate containing "stairs" next to the actor and deliver it to the "stairs" blueprint a few meters away.

All of that is calculated after building the plan itself. Before that all it knows is it's a plan to bring any "stairs" crate to any "stairs" blueprint. This is the solution I'm working with right now. But it doesn't feel right, it feels like a mess.

Adbot
ADBOT LOVES YOU

KillHour
Oct 28, 2007


It feels like a mess because you're missing the entire point of a GOAP. A GOAP is used to tell the AI what it should do next. In order to do that, it needs to have a goal and be able to compare all the different options to achieve that goal and rank them somehow. Knowing how difficult a resource is to obtain is a critical piece of information that you want your AI to be able to act on, or you're going to end up with idiot worker drones dying trying to get at resources inside the player's defenses.

It's not enough to just think about whether the steps are theoretically possible or not. You have to give the steps a cost. For gathering resources, this cost probably takes into account distance, how well protected it is and whether the resource is finite or not, along with other factors. After you figure out all the costs of all the resources, you pick the one with the lowest cost. You can make this more complex by considering other actions that don't necessarily gather the resource directly, but instead lower the cost of gathering the resource (Oil field protected by enemy bunker? Blow up the bunker first). You can take this concept and go crazy with it, adding costs and options for reducing that cost as much as you like. Just keep in mind that you will have to traverse the cost tree similar to pathfinding every time you need to make a decision, so it can become computationally expensive.

Edit:

For example,

https://gamedevelopment.tutsplus.com/tutorials/goal-oriented-action-planning-for-a-smarter-ai--cms-20793

quote:

To help GOAP determine what actions we want to use, each action is given a cost. A high cost action will not be chosen over a lower cost action. When we sequence the actions together, we add up the costs and then choose the sequence with the lowest cost.

Lets assign some costs to the actions:

GetAxe Cost: 2
ChopLog Cost: 4
CollectBranches Cost: 8
If we look at the sequence of actions again and add up the total costs, we will see what the cheapest sequence is:

Needs firewood -> GetAxe (2) -> ChopLog (4) = makes firewood (total: 6)
Needs firewood -> CollectBranches (8) = makes firewood (total: 8)
Getting an axe and chopping a log produces firewood at the lower cost of 6, while collecting the branches produces wood at the higher cost of 8. So, our agent chooses to get an axe and chop wood.

This just uses arbitrary numbers as costs, but in a real game, those costs would be calculated based on other conditions, as above.

Edit 2:

Also remember that GOAP was designed to solve the problem of AI in a relatively constrained environment (it was invented for FEAR), with limited options. A RTS is going to have WAY too large of a search space to use a GOAP by itself without some sort of higher level construct creating relatively simple goals.

KillHour fucked around with this message at 06:23 on Aug 7, 2020

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply