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
OtspIII
Sep 22, 2002

BoneMonkey posted:

Fyi gms2 has had structs and functions forever, they were called scripts and objects. Scripts were worse than functions and are basically gone in the form they used to be. Objects are still around and are basically bloaty structs with with events that run during certain conditions.

Can you actually create objects and modify objects via code mid-game, or are you talking about instances? Instances are useful, but they're by definition tied to a specific room, right?

For more context, I've made games in GM before, but it's not my primary engine and my teaching gig has switched from teaching students Unity first to teaching them Game Maker 2 (and then Unity once they're comfortable with GM). I have enough GM knowledge for anything an intro-level class requires, but I want to make sure that when some of them ask about more advanced topics that I'm not telling them to brute force things that have more elegant default solutions.

Like, let's say I have a game with an inventory. Objects in the inventory have some state associated with them (maybe some are in stacks, some have gems socketed into them, some evolve every 1000 steps I take with them, etc), so they can't be represented with just a single value. Because they're in my inventory they move between rooms a lot, so it feels dumb to have the 'authoritative' version of them exist as instances. They're also a bit too different from each other and complex to store comfortably just as a global array (although it could be done uncomfortably, I guess).

I can think of a few ways to brute force this in GML, but they all seem really painful. I was wondering if there were accepted practices on how to store complex state comfortably, or if the answer is more "try not to make those types of games in GM".

Adbot
ADBOT LOVES YOU

Doc Block
Apr 15, 2003
Fun Shoe
The newest GameMaker Studio, version 2.3, apparently added proper functions and structs so... probably?

edit: Butterscotch Shenanigans is making Crashlands 2 in GameMaker Studio. The first one had inventory and crafting and all that jazz

Doc Block fucked around with this message at 07:08 on Dec 17, 2020

BoneMonkey
Jul 25, 2008

I am happy for you.

OtspIII posted:

Can you actually create objects and modify objects via code mid-game, or are you talking about instances? Instances are useful, but they're by definition tied to a specific room, right?

For more context, I've made games in GM before, but it's not my primary engine and my teaching gig has switched from teaching students Unity first to teaching them Game Maker 2 (and then Unity once they're comfortable with GM). I have enough GM knowledge for anything an intro-level class requires, but I want to make sure that when some of them ask about more advanced topics that I'm not telling them to brute force things that have more elegant default solutions.

Like, let's say I have a game with an inventory. Objects in the inventory have some state associated with them (maybe some are in stacks, some have gems socketed into them, some evolve every 1000 steps I take with them, etc), so they can't be represented with just a single value. Because they're in my inventory they move between rooms a lot, so it feels dumb to have the 'authoritative' version of them exist as instances. They're also a bit too different from each other and complex to store comfortably just as a global array (although it could be done uncomfortably, I guess).

I can think of a few ways to brute force this in GML, but they all seem really painful. I was wondering if there were accepted practices on how to store complex state comfortably, or if the answer is more "try not to make those types of games in GM".



I am talking about instances, which are destroyed when you change room. Unless you set them to persistent. But be careful with that, it's memory leak city. Structs on the other hand are garbage collected. So as long as you have something pointing to the struct then it will stick around. And ds_lists are not garbage collected and do not get destroyed in room changes. So thats a safe place to keep them. (Arrays are garbage collected, buffers arn't, instances are but only on room changes. Particle systems arn't I think, ds_whatevers arn't. Gamemaker is a bit of a mess sometimes.)


Since 2.3 my inventory would be a ds_list I push some structs on. And in those structs I would have some functions that I would run though every step, inventory[| _i].item.update(); or something. Functions created in structs are scoped to that struct. (Unless they are static functions, then they are scoped to the instance calling the function.)

Before 2.3 it would of been a ds_list filled with ds_maps for each item. (Ds_map is basically a more annoying to work with struct, but you can dynamically delete pairs from it.) The ds_map would have a "pointer" to a script which I could use script execute on and then feed it the ds_map and changes the values that way.


2.3 has made this stuff way easier to code. Like before 2.3 you couldn't do:
inventory[| _i].item.update();

you had to do:
Var item = inventory[| _i];
Var script = item[? "Script"];
Script_execute(script, item);

Having played with this a bit, be careful with the noone keyword. If you do:

If(inventory.[| _i].item.update != noone)
{
inventory[| _i].item.update();
}

For some reason this gives you a memory leak. It took me a while to catch that one. What I do now is just have an empty function in item.update if I don't want it to actually do anything. No need for the if check then. (I donno if this is bad practice or not. I'm entirely self-taught.)

Hope that's helpful!
As for the last bit, yeah basically gamemaker can be a bit painful when working with bigger projects. You could always do inventory systems, but man is it so much easier and cleaner since 2.3. but also I think there is value in doing it the hard way first, at least for me. It really made me break down how everything was being accessed and how to get at the data I wanted to change. But man it's so much better now!

BoneMonkey fucked around with this message at 16:03 on Dec 17, 2020

Raenir Salazar
Nov 5, 2010

College Slice
I've went and decided to bite the bullet and redo how I was producing my voronoi diagram to try to make it more of a 'barycentric' dual mesh as described by red blob games: LINK.



Since the issue I was having with the "pinched" connection between two cells, and that issue stemmed from a bad potential result from the delaney/voronoi compute process, where one of the "edges" connecting two voronoi cells was nearly vertical and skewed as well as being narrow and worst of all not even straddling the line connecting the two delaney sites!

A barycentric (centroid) dual mesh here solves my primary issue of resulting in tiny as gently caress gaps by insuring that the gaps are a more modest size. It kinda results in an uglier overall shape though. I am not 100% certain the resulting cells are convex either.

Now I need to redo "ShouldBeThisColour" for the painting algorithm but it should be fairly trivial, now that I'm a little more confident, now I can get the vertices of a voronoi cell and compute whether a given X,Y coordinate is inside that polygon! Which has the side effect of being probably even faster than checking a 2D distance array. Maybe someone suggested this earlier but at the time I couldn't make heads or tails of the triangle.net library but now I have this much ability now.

Raenir Salazar
Nov 5, 2010

College Slice


This was annoyingly exhausting to do. So apparently most "is point p inside a polygon?" code snippets don't actually work if the point being test is on the horizontal/vertical border of said polygon. Might also seem to do with a issue of margins, I found code that accounts for floating point issues and incorporates a margin and I have no idea if its at all performant but with all the difficulties these code snippets resulted in I'm a little done caring.

None of the "is x in polygon" code seem to work very well with slants either, but I imagine this might be a factor of the resolution currently only being 512 and maybe it gets better at larger resolutions.

With this I solve the issue of needing to worry about "pinched" cells and can focus on a more general solution for branches.



This is some ugly bleeding.

Code:
code:
    public static float DistancePointLine2D(Vector2 point, Vector2 lineStart, Vector2 lineEnd)
    {
        return (ProjectPointLine2D(point, lineStart, lineEnd) - point).magnitude;
    }
    public static Vector2 ProjectPointLine2D(Vector2 point, Vector2 lineStart, Vector2 lineEnd)
    {
        Vector2 rhs = point - lineStart;
        Vector2 vector2 = lineEnd - lineStart;
        float magnitude = vector2.magnitude;
        Vector2 lhs = vector2;
        if (magnitude > 1E-06f)
        {
            lhs = (Vector2)(lhs / magnitude);
        }
        float num2 = Mathf.Clamp(Vector2.Dot(lhs, rhs), 0f, magnitude);
        return (lineStart + ((Vector2)(lhs * num2)));
    }


    public static float ClosestDistanceToPolygon(Vector2[] verts, Vector2 point)
    {
        int nvert = verts.Length;
        int i, j = 0;
        float minDistance = Mathf.Infinity;
        for (i = 0, j = nvert - 1; i < nvert; j = i++)
        {
            float distance = DistancePointLine2D(point, verts[i], verts[j]);
            minDistance = Mathf.Min(minDistance, distance);
        }

        return minDistance;
    }

    public static bool IsInsidePolygon(Vector2[] vertices, Vector2 checkPoint, float margin = 0.01f)
    {
        if (ClosestDistanceToPolygon(vertices, checkPoint) < margin)
        {
            return true;
        }

        float[] vertX = new float[vertices.Length];
        float[] vertY = new float[vertices.Length];
        for (int i = 0; i < vertices.Length; i++)
        {
            vertX[i] = vertices[i].x;
            vertY[i] = vertices[i].y;
        }

        return IsInsidePolygon(vertices.Length, vertX, vertY, checkPoint.x, checkPoint.y);
    }

    public static bool IsInsidePolygon(int nvert, float[] vertx, float[] verty, float testx, float testy)
    {
        bool c = false;
        int i, j = 0;
        for (i = 0, j = nvert - 1; i < nvert; j = i++)
        {
            if ((((verty[i] <= testy) && (testy < verty[j])) ||

                 ((verty[j] <= testy) && (testy < verty[i]))) &&

                (testx < (vertx[j] - vertx[i]) * (testy - verty[i]) / (verty[j] - verty[i]) + vertx[i]))
                c = !c;
        }
        return c;
    }

xgalaxy
Jan 27, 2004
i write code
Looks like Unreal Engine 5 is reintroducing a scripting language to live alongside blueprints.
It’s a completely new scripting language from the ground up specifically for UE.

https://twitter.com/saji8k/status/1339709691564179464?s=20

Havn’t watched the video yet. Looks like:
- first class support for coroutines based on the "Wait*" functions.
- some sort of pointer type, possibly in the vein of Swift
- significant white space

xgalaxy fucked around with this message at 18:33 on Dec 18, 2020

more falafel please
Feb 26, 2005

forums poster

xgalaxy posted:

Looks like Unreal Engine 5 is reintroducing a scripting language to live alongside blueprints.
It’s a completely new scripting language from the ground up specifically for UE.

https://twitter.com/saji8k/status/1339709691564179464?s=20

Havn’t watched the video yet. Looks like:
- first class support for coroutines based on the "Wait*" functions.
- some sort of pointer type, possibly in the vein of Swift
- significant white space

$5 says it's effectively text-based Blueprint, which is just visual UnrealScript (Blueprints are compiled to UnrealScript bytecode). It'll be easier to diff/merge at least!

Raenir Salazar
Nov 5, 2010

College Slice
One thing I am currently finding to be interesting is while its pretty simple to prove if a water tile is a landlocked lake (like the Ural Sea) by simply checking if all of its neighbours are land tiles, its a little more difficult to prove the reverse, that a given tile is on the ocean.

I think there's a couple of heuristics that might be reliable although not guaranteed.

1. Are all neighbours water tiles and the number of neighbours 3 or greater?

This is probably the simplest. I don't intend to have massive landlocked oceans, but it's conceivable that such a large ocean could exist, so this test isn't 100% reliable, only like 80%.

2. Do like a breadth-width search and count the number of sea tiles, if this number is sufficiently large, say 60% or more of all sea tiles, it is probably a ocean tile.

3. For a tile that originates near or adjacent to land, work my way following the coast and see if I can make my way back to the start point by circumnavigating the land. This was an interesting idea, similar to how to escape a maze, but flawed if somehow I am inside a really big lake it would give inaccurate results.

I think (2) is best, even better I only need to do it once and then compile a list of gauranteed sea-tiles to reference later for a sped up search.

I think I need some combination of approaches if I want something close to 99% certainty that a given tile is a open ocean tile.

-Can I, from the start point, get to something between 60% to 80% of all water tiles?
-Can I, from this start point, find land, and from that land, circumnavigate the land back to that point? This land being the land belonging to the largest continent.
--Addendum, can I reach *all* islands/contingents from the start point? (Sans islands that are interior to a lake?)
-Can I reach a majority of the edges of the map?

I think the second point and its addendum probably guarantees the oceanness of a particular tile.

Raenir Salazar
Nov 5, 2010

College Slice


Pretty much happy with it now. There's a bit of polish and refinements left to give it, some optimizations, and maybe a few edge cases to cover that I thought off but aren't really present in this example, but I'm pretty much done with this and can go back to working on the height map generation, making it faster, moving it off the main unity thread so loading it is more tolerable and actually working on generating the 5k by 2k map version but in a reasonable time.

anatomi
Jan 31, 2015

Just check the salinity.

(Looks great, by the way).

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I've been trying to integrate NoesisGUI into my project after externally jerking around with WPF for the past two months or so. My impression is that NoesisGUI generally works but you get into trouble whenever you try to use some workaround thing to get a precise behavior that works in regular WPF. There are two examples that I'm dealing with right now:
1. Custom comparers work completely differently between NoesisGUI and WPF. You have to subclass something completely different and it integrates differently.
2. I also have a custom converter that makes sure I can fit five buttons work of buttons into my list view. NoesisGUI passes in floats when WPF would normally pass in doubles, and it refuses to cast them directly. Afterwards, I had to conclude it's not actually working at all in NoesisGUI and I'm trying to determine why.

You'd normally do everything targeting Unity and not lean on actual WPF shenanigans, but it's hard to do that when you are searching around online about how to do this or that thing.

There's a bit of #preprocessor shenanigans you need to do if you were planning for some code to be properly recognized between WPF and NoesisGUI.

There's also some peculiarity with drawing that I haven't figured out. There's a bunch of purple around my buttons that I am assuming is a screwing with transparency but I haven't figured out what it actually is yet.

Something I haven't yet figured out is how a gamepad (or keyboard, for that matter) should work with all this stuff. I am using InControl and it didn't just magically do anything.

On the plus side, I was assuming it would be a huge problem to switch between my controls for some reason with asset paths and whatnot, but that worked immediately once I got my main menu to show up.

Raenir Salazar
Nov 5, 2010

College Slice
Currently optimizing my code a bit.

e: Who likes updates. And lines. Lots of lines.



Basically I went and implemented Sebastian Lague's line drawing algorithm from his caves tutorial, however I noticed errant pixels in like a tiny handful of situations leaked across the other side of the line, usually at most 1 per a given cell, and most importantly seemed to be because the pixels the line drawing algorithm picked were a little odd.

Overall I'm not convinced that the "leaked" pixels from earlier updates is just a floating point/resolution issue due to the resolution being 512 by 512 originally. So even though I had OnDrawGizmos for the "lines" surrounding the cells, it seemed like something was wrong but was probably a false positive.

When I actually draw the lines and apply it to the texture directly there appears to be no pixel leakage, the one or two pixels that do leak seem to be because as mentioned the line drawing algorithm was probably not appropriate for my use case.

I went and found Red Blob Games nifty article on the subject and implemented each line drawing algorithm one by one testing them for leaking pixels and at the end "supercover_line" seems to give best results.

Some lines are a little thicker in places than others but its not very noticable at this scale, but I can't spot any leaked pixels so this is "Good Enough(tm)" for me.

I mostly worked out the kinks after my initial pass of optimizations, switching lists to hashsets since most of the time I'm only checking if something is contained in a list and iterating over it with foreach loops so I don't need the indexing of a List and HashSets are supposed to be O(1) for lookup. I implemented the Equals/GetHashCode overrides for my VoronoiCell and TileBlob classes to make use of this, and then rewrote a lot of my code for additional smaller optimizations like having each cell keep track of its friends (cells in the same blob) separately from its enemies (cells not in the same blob) to avoid wasteful iteration.

I didn't keep a running benchmark unfortunately so I don't know if I ended up saving any time at all in the end, and either way the whole thing is around 10 seconds to load, but I'm liking these results.

I think I'm sufficiently satisfied that everything works as it should to now go back and give my simplex noise height map generation another go.

Raenir Salazar fucked around with this message at 06:04 on Dec 29, 2020

TheHoosier
Dec 30, 2004

The fuck, Graham?!

Hi, me again with another problem that likely has an obvious solution. So here's this:

quote:

IEnumerator BossExplosion()
{
//Explosion vars
Vector2 bossPos = transform.position;
Vector2 expPos = Random.insideUnitCircle * 2 + bossPos;
float random1 = 1f;
float random2 = 2f;
float expTimer = UnityEngine.Random.Range(random1, random2);

for(int i = 0; i <= 4; i++)
{
GameObject bossExp = Instantiate(_bossDeathVFX, expPos, transform.rotation);
Destroy(bossExp, 1);
yield return new WaitForSeconds(expTimer);
}

}

The idea is that upon boss death, I want to trigger multiple explosions around the boss sprite pivot. Like bang, explosion fades, another spawns, repeat, boss dies after 5 seconds. I didn't post the rest of the script because everything else is working great except this. The problem is: The initial position of instantiation is random as it should be, but each subsequent instantiation after the first occurs at the exact same spot. I've tried assigning UnityEngine.Random.Range to the X/Y values, i'm currently trying the Random.insideUnitCircle method, and i've tried an offset. I know there's something incredibly obviously that I'm missing, but I can't figure out what.

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
You need to recalculate expPos each iteration of the loop.

TheHoosier
Dec 30, 2004

The fuck, Graham?!

TooMuchAbstraction posted:

You need to recalculate expPos each iteration of the loop.

That did it. Thank you. I knew it was something really simple. I had it in my head that expPos would recalculate each time Instantiate was called, for some reason.

jizzy sillage
Aug 13, 2006

TheHoosier posted:

That did it. Thank you. I knew it was something really simple. I had it in my head that expPos would recalculate each time Instantiate was called, for some reason.

The vars you set up stay the same between yields, so it doesn't recalculate. If you instantiated a new copy for a new boss, it'd have a different expPos but it would be the same for each of its loops.

StashAugustine
Mar 24, 2013

Do not trust in hope- it will betray you! Only faith and hatred sustain.

Hey I'm working on a 2d top-down shooter as a personal project to learn Godot; and I'm being tripped up by what I'm pretty sure is an obvious logic issue. I want to implement a grid of waypoints for doing quick estimates of line-of-fire (and other things) by having each one toss out raycasts on startup (right now getting eight sectors, each of which does a raycast down the center along 8 cardinals) and finds the farthest obstacle it hits. Then whenever desired, it takes the direction and distance to a point (usually the player), uses the direction to figure out which sector it's in, and if it's closer than the farthest obstacle it detected, then it returns that the area is potentially unsafe. But the system is some combination of too rough and possibly buggy and thus produces unhelpful results:



It's clearly flagging a bunch of stuff as safe that can be shot and stuff as unsafe when it can't. I've tried adding some extra raycasts but it just makes the whole thing wonkier; and I don't think the problem is bugs, just that it's too granular.

e: the problem is most pronounced near to narrow edges, obviously, but it's still very noticeable everywhere

StashAugustine fucked around with this message at 20:02 on Jan 8, 2021

Raenir Salazar
Nov 5, 2010

College Slice
Maybe try putting in some more debugging stuff, like gizmos/lines, etc to see what's happening and where it might be tripping up? Seems like there must be something big and obvious you're missing.

StashAugustine
Mar 24, 2013

Do not trust in hope- it will betray you! Only faith and hatred sustain.

Hm; I've been verifying with drawing lines and displaying text (side note, updating a five point line and three lines of text for a thousand instances every frame is some serious chugging); and it seems like it's correctly identifying the sector and the distances; so the problem is probably just logical. Like it makes sense- in the screenshot above, the lowest line of incorrectly "safe" points are saying "yeah he's directly to the right, he's farther away than that wall that's directly to the right, therefore he can't shoot me." Adding additional raycasts and shifting the position of the sectors seems to just be changing the problem; I think I need to figure out a better way to resolve this.

late edit since I hate finding a question and not an answer: The first strategy that helped was making N raycasts in a circle and storing the distances; then given an angle find floor and ceiling of angle / (2pi /N) and call those results. The second strategy was remembering that I have more memory than a PS2-era game and setting N to 360.

StashAugustine fucked around with this message at 01:16 on Jan 9, 2021

limaCAT
Dec 22, 2007

il pistone e male
Slippery Tilde
How janky/difficult is to handle physics in unity? Like when you have a forklift trying to carry a crate?
(mind you my experience with unity is still extremely limited, the forklift is fully kinematic).

I was thinking about making the crate glue itself to the forklift when the teeth touch the bottom of the crate but then again I wonder how I can handle when the forklift has to climb a ramp or moves too fast with too many crates...

https://twitter.com/limaCAT/status/1350459148614438913?s=19

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

limaCAT posted:

How janky/difficult is to handle physics in unity? Like when you have a forklift trying to carry a crate?
(mind you my experience with unity is still extremely limited, the forklift is fully kinematic).

I expect that trying to let the physics simulation handle everything will not work well. I believe the standard way to handle this is to detect when object A has "grabbed" object B, and then make object B a child of object A until it is released. As a child it will move exactly as the parent object does, which is unrealistic but avoids physics issues. You can hand-program some basic "reactions" to movement to have the crate slide back and forth in response to the forklift moving, if you want more realism.

Raenir Salazar
Nov 5, 2010

College Slice
There might be a way to add a degree of dampening to the physics as well so its less finnicky.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

limaCAT posted:

How janky/difficult is to handle physics in unity? Like when you have a forklift trying to carry a crate?
(mind you my experience with unity is still extremely limited, the forklift is fully kinematic).

I was thinking about making the crate glue itself to the forklift when the teeth touch the bottom of the crate but then again I wonder how I can handle when the forklift has to climb a ramp or moves too fast with too many crates...

https://twitter.com/limaCAT/status/1350459148614438913?s=19

Physics in Unity is easy! (as easy as physics is in anything)

The thing is there's a loooot of different ways to skin this cat.

TooMuchAbstraction posted:

I expect that trying to let the physics simulation handle everything will not work well. I believe the standard way to handle this is to detect when object A has "grabbed" object B, and then make object B a child of object A until it is released. As a child it will move exactly as the parent object does, which is unrealistic but avoids physics issues. You can hand-program some basic "reactions" to movement to have the crate slide back and forth in response to the forklift moving, if you want more realism.

I agree that in situations like this I tend to kinda "hard-code" the physics. But what you can do is basically turn the Unity physics calculations on and off as needed.

Parenting is the simple way, but there can be funny consequences too. You can also just have some script that updates the positions along with the parent object's updates.

What you'll want to do is either set the box as "isKinetic = true" or set "rigidBody.rigidBodyConstrants = RigidBodyConstrants.All" either will stop the physics updating the box, and freeze it in place. Then if you parent it, it'll just always follow the motion of the forklift, or you can manually move the box if you run into issues with parenting.

Raenir Salazar posted:

There might be a way to add a degree of dampening to the physics as well so its less finnicky.

Yes all unity RigidBodies have two dampening values which can be used to make them less bouncy. It may be possible to get acceptable behavior just by making it have more friction and letting unity physics carry everything.

The big question here is how do you want it to handle?

If you want something where you actually can drop the box if you aren't careful about your speed, then sticking to unity physics is right. You'll get a QWOP / Fall Guys style experience with the box sliding around on the forklift, and you can modify the dampening to adjust how much it slides around.

But if you want something more mechanical, where the player picks up a box and then it stays on the lift until you put it down, then you'll want to do the above with either setting kinetic or setting constraints and then letting the parenting or a script just move the transform and ignore the physics calcs until the box is back on the ground, in which case you set isKinetic back to false or you turn the constraints back to RigidBodyConstraints.None.

Oh, also your hitboxes are going to be super important if you're using the base unity physics calcs. You'll want to look at how the hitboxes are set up on your forklift and possibly modify them. (A big "invisible wall" would make it harder for the box to flip out, for instance) If you're using a meshCollider for the forklift, consider switching. A bunch of box colliders will be faster and more accurate, even though meshcolliders are very convenient.

So there's some design question here, and intent questions. Can the box bump into objects while it is on the forklift? Should that knock the box free or not? Things like that.

Zaphod42 fucked around with this message at 23:25 on Jan 16, 2021

Doc Block
Apr 15, 2003
Fun Shoe
Make the object you're lifting heavier, and ramp the movement of the forklift instead of having it instantly start/stop. And yeah, increase friction and physics damping.

edit: also, see if Unity has a maximum physics velocity setting, so you can put a cap on the crate speed so it doesn't catch an edge weirdly and get launched into space.

Doc Block fucked around with this message at 23:31 on Jan 16, 2021

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!

Doc Block posted:

Make the object you're lifting heavier, and ramp the movement of the forklift instead of having it instantly start/stop. And yeah, increase friction and physics damping.

edit: also, see if Unity has a maximum physics velocity setting, so you can put a cap on the crate speed so it doesn't catch an edge weirdly and get launched into space.
I feel like if you're going for that kind of 'realistic' physics then you also want to make the forklift itself not-kinematic, and drive it by applying forces to it, which then means you shouldn't need to worry about the "launch into space" effect, which usually results from unresolvable contacts between kinematic and rigidbody physics.

But if you go that way then you have to really think about where you're going to put the join between fake and real physics. My place of choice would be where the forklift touches the ground, because you don't want to deal with wheel rotations and poo poo, so then you fake it by applying large fake-friction forces so it can't slide the way the wheels aren't pointing (unless it's going fast enough to overcome the fake friction, lol drifting forklift race), and "try to match the target speed of the wheel" forces along each wheel-forward axis.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

roomforthetuna posted:

I feel like if you're going for that kind of 'realistic' physics then you also want to make the forklift itself not-kinematic, and drive it by applying forces to it, which then means you shouldn't need to worry about the "launch into space" effect, which usually results from unresolvable contacts between kinematic and rigidbody physics.

But if you go that way then you have to really think about where you're going to put the join between fake and real physics. My place of choice would be where the forklift touches the ground, because you don't want to deal with wheel rotations and poo poo, so then you fake it by applying large fake-friction forces so it can't slide the way the wheels aren't pointing (unless it's going fast enough to overcome the fake friction, lol drifting forklift race), and "try to match the target speed of the wheel" forces along each wheel-forward axis.

This is a good call if you're going that way yeah

TIP
Mar 21, 2006

Your move, creep.



limaCAT posted:

How janky/difficult is to handle physics in unity? Like when you have a forklift trying to carry a crate?
(mind you my experience with unity is still extremely limited, the forklift is fully kinematic).

I was thinking about making the crate glue itself to the forklift when the teeth touch the bottom of the crate but then again I wonder how I can handle when the forklift has to climb a ramp or moves too fast with too many crates...

https://twitter.com/limaCAT/status/1350459148614438913?s=19

One of the biggest issues I see in your video is your physics items going through the collider and then bouncing back out as you drive the forklift forward.

You need to adjust the CollisonDetectionMode to prevent that from happening.

Here's the manual page explaining the various continuous collision detection modes:
https://docs.unity3d.com/Manual/ContinuousCollisionDetection.html

I found this advice on the Unity boards:

quote:

If it's two Dynamic Colliders, you have to set one of the object's Rigidbody Collision Detection to Continuous, and the other object's Rigidbody Collision Detection to Continuous Continuous Dynamic.
If it's one Static Collider and one Dynamic Collider, set the object's Rigidbody Collision Detection to Continuous.

PS: Static Collider means a GameObject without a Rigidbody. Dynamic Collider means a GameObject with a Rigidbody.

It's worth noting that Continuous and Continuous Dynamic collision detection modes have an impact on the Physics performance.

Doc Block
Apr 15, 2003
Fun Shoe

roomforthetuna posted:

I feel like if you're going for that kind of 'realistic' physics then you also want to make the forklift itself not-kinematic, and drive it by applying forces to it, which then means you shouldn't need to worry about the "launch into space" effect, which usually results from unresolvable contacts between kinematic and rigidbody physics.

Doesn’t have to mean “realistic”, just not instantly on/off, so the load the player is carrying doesn’t thrash around. A 1/10th second ramp would help a lot.

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!

Doc Block posted:

Doesn’t have to mean “realistic”, just not instantly on/off, so the load the player is carrying doesn’t thrash around. A 1/10th second ramp would help a lot.
By 'realistic' in inverted commas I meant any kind of physics where the load doesn't get artificially linked to the carrier. If it's artificially linked it won't fly into space because it's linked. If it's not artificially linked then you should probably not have the carrier be kinematic, because the join between kinematic objects and rigidbody objects is lovely even when it's "occasional contact". It's *very* lovely if one is trying to carry the other.

Boz0r
Sep 7, 2006
The Rocketship in action.
Has anyone tried the Bevy game engine for Rust? I've been meaning to learn Rust for some time but never really got around to it.

Khorne
May 1, 2002

Boz0r posted:

Has anyone tried the Bevy game engine for Rust? I've been meaning to learn Rust for some time but never really got around to it.
I've used it a little. If you're just looking to play around with Rust and do a learning project then it's fun. One big problem is the documentation really isn't there. They've allegedly been holding off on writing documentation because it's rapidly changing.

The example/tutorial ecosystem is also largely not there. Most of the examples are trivial, do things in a way that is not good for a full-featured game, and don't answer questions like "how do you handle simulation tick rate vs rendering tick rate" or "how do you stop one set of systems from running on any given tick" or "how does this engine intend to have you do [common thing]" and the documentation doesn't answer it either. The documentation seems to assume all you'll need is their ECS and its scheduling, and the example/tutorial projects people have built do just that.

You can go on discord and ask questions and people will answer. Certain things aren't in the engine yet, for example batching. Scene switching also wasn't great in 0.3 and I haven't checked how it is in 0.4. But these are on the todo list, and the project is moving at a decent pace.

I've been writing a game server in rust for fun, but it's not clear what I'll use for a client.

Khorne fucked around with this message at 18:07 on Jan 19, 2021

Narzack
Sep 15, 2008
Does anyone have experience with writing text adventure/interactive fiction? I'm wondering what the best accepted practice is- right know, I'm writing most of the text in word, just to get the n arrative and ideas down. After I get that sorted, I plan to explore the different engines to start inputting all the information. Is this normal or backwards?

more falafel please
Feb 26, 2005

forums poster

Narzack posted:

Does anyone have experience with writing text adventure/interactive fiction? I'm wondering what the best accepted practice is- right know, I'm writing most of the text in word, just to get the n arrative and ideas down. After I get that sorted, I plan to explore the different engines to start inputting all the information. Is this normal or backwards?

Twine is the typical engine used for text adventure/narrative games -- I imagine even if you're planning on putting it in a different game, a tool like twine would be useful to organize your structure beforehand.

CodfishCartographer
Feb 23, 2010

Gadus Maprocephalus

Pillbug

more falafel please posted:

Twine is the typical engine used for text adventure/narrative games -- I imagine even if you're planning on putting it in a different game, a tool like twine would be useful to organize your structure beforehand.

Twine is fantastic for this! There's also a scripting language called Ink that may be appropriate depending on your needs, it's specifically designed around making more adventure-style games. Might be a bit more than needed, but it's neat and I want to share it:

https://www.youtube.com/watch?v=3eYHtDGOM8U

Catgirl Al Capone
Dec 15, 2007

twine is good but i'll say that while ymmv i vastly prefer 1.x to 2.x

Narzack
Sep 15, 2008

more falafel please posted:

Twine is the typical engine used for text adventure/narrative games -- I imagine even if you're planning on putting it in a different game, a tool like twine would be useful to organize your structure beforehand.

This is a great idea, thanks.

CodfishCartographer posted:

Twine is fantastic for this! There's also a scripting language called Ink that may be appropriate depending on your needs, it's specifically designed around making more adventure-style games. Might be a bit more than needed, but it's neat and I want to share it:

https://www.youtube.com/watch?v=3eYHtDGOM8U

I'll download this, too, and fool around with it, thanks!

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!

Narzack posted:

Does anyone have experience with writing text adventure/interactive fiction? I'm wondering what the best accepted practice is- right know, I'm writing most of the text in word, just to get the n arrative and ideas down. After I get that sorted, I plan to explore the different engines to start inputting all the information. Is this normal or backwards?
I hadn't heard of Twine, but I have played decent text adventures done with TADS and Inform (which it turns out mentions Twine on its front page). Those games were made by people whose job is software, so the tools might be shaped for programmer-brain, which may or may not be your preference.

minidracula
Dec 22, 2007

boo woo boo

Narzack posted:

Does anyone have experience with writing text adventure/interactive fiction? I'm wondering what the best accepted practice is- right know, I'm writing most of the text in word, just to get the n arrative and ideas down. After I get that sorted, I plan to explore the different engines to start inputting all the information. Is this normal or backwards?
Echoing roomforthetuna, I'm a fan of both "old school" (purely a relative charcterization) IF languages like TADS and Inform, as well as newer tools for similar (but different from Ye Olde Text Adventures) things like Twine (though like CYBEReris, I stuck with Twine 1.x; 1.4.2 is what's on my laptop as I check just now).

Inform 7 in particular is very different from Inform 6, which won't mean anything to you if you're coming to this brand new, but you may want to check it out as it takes a very interesting approach to the whole problem, and is pretty interesting in its own right.

As for your question, I don't think there's a single accepted best practice per se, but I don't think writing ideas down (in whatever you choose) to get them out of your head and into a moldable and probe-able shape is a bad idea.

minidracula fucked around with this message at 07:23 on Feb 2, 2021

a cyberpunk goose
May 21, 2007

re: forklift and avoiding rigibodies moving too quickly: often i'll use an AnimationCurve component and use the Evaluate() method on it to do quick & dirty "animation"y things for stuff, or simulating a transmission torque etc

as long as you stick to Acceleration for most types of programmatic physics input within FixedUpdate, and keep an acceleration curve, things are surprisingly stable

a cyberpunk goose fucked around with this message at 09:39 on Feb 2, 2021

Adbot
ADBOT LOVES YOU

MuffiTuffiWuffi
Jul 25, 2013

Narzack posted:

Does anyone have experience with writing text adventure/interactive fiction? I'm wondering what the best accepted practice is- right know, I'm writing most of the text in word, just to get the n arrative and ideas down. After I get that sorted, I plan to explore the different engines to start inputting all the information. Is this normal or backwards?

"Interactive fiction" has kind of expanded into a wider category than it has historically been, so I'm not really sure how to answer that. However, I think if you have a strong idea of what the gameplay should look like, then picking an engine later might be okay. Just note that many of the engines commonly used for IF are different enough that the resulting game might end up drastically different, and that unless you're literally doing a CYOA-style game it's probably going to be more complicated than directly inputting all the information.

Depending on what kind of game you want to make there might be a very obvious answer to "what engine should I use" - for example if you're making a CYOA with no images or UI variations ChoiceScript would be very straightforward, but if you're doing a parser game you'd have to use an explicit parser game engine. Twine is a generally cool general-purpose engine, but it isn't really optimized for parser stuff. If you can describe some of what you're looking for somebody could probably give more targeted advice.

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