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
Raenir Salazar
Nov 5, 2010

College Slice

KillHour posted:

You realized the problem that a hash of the text wouldn't be well distributed so you added the timestamp but that just makes it pointless since it would be indistinguishable from any other RNG. Instead, you should pick a post at random and feed the text into GPT-3 as a prompt and the game should do whatever comes out of it. Call it Dungeons and Virgins.

Edit:



Good enough. Ship it.

LOL that's literally how my scrums go.

Adbot
ADBOT LOVES YOU

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
I got the basic ghost ship effect working, as a postprocessing effect:

https://i.imgur.com/eDLK62Q.mp4

It helps that I'd already solved a lot of the basic issues when I made a postprocessing effect that applies chromatic aberration to only part of the screen.

The only downside to this solution is that it doesn't respect occlusion, because the ships are rendered on their own private layer and then composited in. That is in principle fixable, but I plan to "fix" it by only having AI ghost ships show up in a mission that has no terrain :v: It's not too noticeable when it's just the water like in the video above. In other missions, the only possible ghost will be the player (if they're using the Faulty Cloaking Device system they won from the Halloween event mission), and odds are they won't be occluded by other stuff very often.

Raenir Salazar
Nov 5, 2010

College Slice
It also seems to be eating your frames. :D

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

Raenir Salazar posted:

It also seems to be eating your frames. :D

That's the video being 30FPS instead of 60.

I was wrong, it's in the game. Easily fixed by moving some logic from Update to LateUpdate though.

TooMuchAbstraction fucked around with this message at 20:09 on Sep 30, 2021

Raenir Salazar
Nov 5, 2010

College Slice

TooMuchAbstraction posted:

That's the video being 30FPS instead of 60.

I was wrong, it's in the game. Easily fixed by moving some logic from Update to LateUpdate though.

:hmmyes:

A good deed was done today.

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
One hour to get the basic concept working. More like five to get occlusion working.

https://i.imgur.com/4RCpLiI.mp4

I hate having to deal with depth buffers :negative:

KillHour
Oct 28, 2007


It looks like it's under the water. Is that what you were going for?

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

KillHour posted:

It looks like it's under the water. Is that what you were going for?

The goal is a cross between "spooky ghost ship" and "faulty cloaking device"; the latter is a special cosmetic item that the player will get access to when they complete the Halloween mission.

It'd look more like it was on top of the water if it could cast shadows on the water, but doing that would require even more draw calls and gently caress it, I've spent too much time on this thing already.

zachol
Feb 13, 2009

Once per turn, you can Tribute 1 WATER monster you control (except this card) to Special Summon 1 WATER monster from your hand. The monster Special Summoned by this effect is destroyed if "Raging Eria" is removed from your side of the field.
Something about the way you're determining transparency is really strange, the end effect on first glance is that it just looks like it's a steamship getting covered by smoke. Like I think transparency is determined by some shader that would normally get used for clouds or waves or smoke, but the end result is too much transparency in some areas along with not enough in others that makes it look like something happening over the ship, instead of the ship itself being translucent.

xzzy
Mar 5, 2009

I think the wake being visible through the ship throws things off too. I appreciate it's irritating to mask that out, but that's probably where the underwater look comes from.

Maybe add a gradient where the bottom of the boat is less transparent than the top of it? Or a fresnel approach where the edges of the silhouette are less transparent. When I was googling for fresnel examples I found this, which maybe you'll find the approach helpful.

https://www.artstation.com/artwork/R3L44v

The fresnel and diffraction really helps in that case.

TIP
Mar 21, 2006

Your move, creep.



I also think the effect looks weird, it kinda reads to me as a graphical glitch.

What if instead of doing all that you just spawned a bunch of fog particles at the positions of the ship's vertexes? It would give it kind of a ghostly appearance being wrapped in fog and trailing it as it goes and it would also somewhat camouflage it if the fog is a similar color to the ocean.

CodfishCartographer
Feb 23, 2010

Gadus Maprocephalus

Pillbug
In Unity, is there an easy way to calculate how to get a rigibody moving at a desired velocity? Like, say I want a rigidbody moving at 10 units per second, or a velocity magnitude of 10. If there a simple way to calculate what amount of force to add for a given rigidbody's drag or vice versa? I've googled around but can't find anything, and it'd be nice to not need to just fiddle with both settings back and forth until I find something that works, especially if I wind up deciding to adjust the drag later on or something.

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

zachol posted:

Something about the way you're determining transparency is really strange, the end effect on first glance is that it just looks like it's a steamship getting covered by smoke. Like I think transparency is determined by some shader that would normally get used for clouds or waves or smoke, but the end result is too much transparency in some areas along with not enough in others that makes it look like something happening over the ship, instead of the ship itself being translucent.

It is literally something happening over the ship. I can't make the ship be transparent using traditional methods without replacing the materials on it. But that would mean that you could no longer take advantage of the wide range of other cosmetics you can apply to your ship. So instead the ship is getting composited into the view, with some transparency applied to it based on sampling a cloud noise texture. Because this happens in screen space, anything that relies on changing appearance as a function of position would be a colossal pain to implement; just getting occlusion working was hard enough already!

Tip posted:

I also think the effect looks weird, it kinda reads to me as a graphical glitch.

What if instead of doing all that you just spawned a bunch of fog particles at the positions of the ship's vertexes? It would give it kind of a ghostly appearance being wrapped in fog and trailing it as it goes and it would also somewhat camouflage it if the fog is a similar color to the ocean.

I'm OK with it looking weird and kind of unrealistically odd/glitchy, so long as it looks weird in a "this is strange" sense as opposed to a "this fundamentally isn't working for me" sense. Part of the goal of this entire concept is to reference the Philadelphia Experiment, a supposed attempt to make a cloaking device for naval ships. Subverting traditional expectations for rendering feels not out-of-the-question to me, for that kind of situation. That said, I could attach particle emitters; here's an experiment with sticking a fog emitter on the ship:

https://i.imgur.com/yBS3Ncf.mp4

The reason for the colors is that it's coloring the particles based on the vertex colors of the mesh, and I use red/blue vertex colors to encode data about where the ship's decks and waterline are. I think it's a neat effect to have the colors like that though.

Ruzihm
Aug 11, 2010

Group up and push mid, proletariat!


TooMuchAbstraction posted:

It is literally something happening over the ship. I can't make the ship be transparent using traditional methods without replacing the materials on it. But that would mean that you could no longer take advantage of the wide range of other cosmetics you can apply to your ship. So instead the ship is getting composited into the view, with some transparency applied to it based on sampling a cloud noise texture. Because this happens in screen space, anything that relies on changing appearance as a function of position would be a colossal pain to implement; just getting occlusion working was hard enough already!

I'm OK with it looking weird and kind of unrealistically odd/glitchy, so long as it looks weird in a "this is strange" sense as opposed to a "this fundamentally isn't working for me" sense. Part of the goal of this entire concept is to reference the Philadelphia Experiment, a supposed attempt to make a cloaking device for naval ships. Subverting traditional expectations for rendering feels not out-of-the-question to me, for that kind of situation. That said, I could attach particle emitters; here's an experiment with sticking a fog emitter on the ship:

https://i.imgur.com/yBS3Ncf.mp4

The reason for the colors is that it's coloring the particles based on the vertex colors of the mesh, and I use red/blue vertex colors to encode data about where the ship's decks and waterline are. I think it's a neat effect to have the colors like that though.

just speaking for myself i think it looks cool :hai:

giogadi
Oct 27, 2009

CodfishCartographer posted:

In Unity, is there an easy way to calculate how to get a rigibody moving at a desired velocity? Like, say I want a rigidbody moving at 10 units per second, or a velocity magnitude of 10. If there a simple way to calculate what amount of force to add for a given rigidbody's drag or vice versa? I've googled around but can't find anything, and it'd be nice to not need to just fiddle with both settings back and forth until I find something that works, especially if I wind up deciding to adjust the drag later on or something.

I haven’t worked with unity for a while, but I believe you can use AddForce(velocity_change, ForceMode.Velocity). This will automatically compute the force required to change your body’s velocity by the given amount.

But note that your body is still reacting to physics after this: so if there’s friction, the resulting speed might not be exactly the speed you expect. If you have no friction or other forces on your body, it should give you exactly the speed you want.

Edit: if you *do* have external forces/drag etc., as far as I know the only way to get the object to go at a constant desired speed is to implement a controller - I mean “controller” in the classical sense of something that continuously observes and applies forces to the body to try to maintain a constant speed. Think of it like cruise control on a car. If I weren’t phone posting I’d give you some links to read up on this

giogadi fucked around with this message at 21:03 on Oct 1, 2021

giogadi
Oct 27, 2009

“PID control” is a common approach to the problem of “how do I adjust the amount of x I apply to the system so that property y is close to what I want” where in your case, x is force and y is velocity.

But taking one step back: if your rigid body only ever moves at constant velocity, you should consider making it kinematic and directly controlling velocity. Of course, if it’s important for your object to also react to other kinds of effects like drag and friction, then you have no choice but to implement a controller such as PID.

Unfortunately, even a PID needs to be tuned every time you change settings for your rigid body, but it should be more robust than picking a constant force and hoping that doesn’t drift.

CodfishCartographer
Feb 23, 2010

Gadus Maprocephalus

Pillbug
Thanks for the info! And yeah for now I might just go with a controller rather than a rigidbody.

For more context, I'm trying to recreate the movement of Titanfall 2 as close as possible to the original game as a learning exercise. Right now I'm trying to get the momentum + acceleration spot-on, and waffling between a controller and a rigidbody. With a controller I have to manually set up things like acceleration and deceleration, but then I have more fine control to try to get the recreation more accurate. For example, it takes 4 frames to get up to walking speed from a standstill in TF2, and it's super easy to just tell a controller how much speed to increase each frame to get there. But with a rigidbody, trying to get exactly "4 frames to max speed" is surprisingly tough, since so much of it varies with the force being applied and its drag.

Speaking of all this, I've ran into another slight problem with using a controller here - normalizing the speed for diagonals. That is, I'm not sure where the best place to normalize the movement vector would be. Here's how I have it set up:

code:
void MoveCheck()
    {
        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        float accel = speedGainPerSec * Time.deltaTime;
        float decel = speedLossPerSec * Time.deltaTime;

        float maxSpeed = sprinting ? maxSpeedSprint : maxSpeedWalk;

        Vector3 localVelocity = transform.InverseTransformDirection(moveDir); //create a new vector that's based on the player's world movement converted to local movement to get the player's relative momentum

        if (x == 0) //if horizontal controls are NOT being pressed, decelerate or stop horizontal movement
        {
            if (Mathf.Abs(localVelocity.x) > decel)
                localVelocity.x -= Mathf.Sign(localVelocity.x) * decel;
            else
                localVelocity.x = 0;
        }
        else //if horiz controls ARE being pressed, accel up to max speed
        {
            if (Mathf.Abs(localVelocity.x) + accel < maxSpeed)
                localVelocity.x += Mathf.Sign(x) * accel;
            else
                localVelocity.x = Mathf.Sign(x) * maxSpeed;
        }

        if (z == 0) //same as above, but vertical controls
        {
            if (Mathf.Abs(localVelocity.z) > decel)
                localVelocity.z -= Mathf.Sign(localVelocity.z) * decel;
            else
                localVelocity.z = 0;
        }
        else
        {
            if (Mathf.Abs(localVelocity.z) + accel < maxSpeed)
                localVelocity.z += Mathf.Sign(z) * accel;
            else
                localVelocity.z = Mathf.Sign(z) * maxSpeed;
        }

        moveDir = transform.TransformDirection(localVelocity); //transform local movement back to world movement and set it to the Move vector

        velocity.x = moveDir.x;
        velocity.z = moveDir.z;

     	controller.Move(velocity * Time.deltaTime);
    }
If I normalize the "velocity" vector (or the moveDir vector) then it loses the adjustment of acceleration / deceleration, but since I'm applying those on a per-axis basis I'm not sure where the best place to normalize it would be. As this code is now, you move faster when walking diagonally which isn't what I want.

(right now this code also doesn't account for instantly changing direction, such as strafing right and then immediately switching to strafing left - that currently happens instantly. I still need to implement correctly slowing the player down before accelerating them the opposite direction)

CodfishCartographer fucked around with this message at 21:40 on Oct 1, 2021

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 might find this talk to be useful. It goes over how one of the Wolfire devs set up their character controller. It's from the standpoint of needing to animate the thing, but I'd bet there's some useful info in there anyway.

Ruzihm posted:

just speaking for myself i think it looks cool :hai:

Thank you!

CodfishCartographer
Feb 23, 2010

Gadus Maprocephalus

Pillbug
Wound up solving my normalization problem: I simply reduced the max speed when both a horizontal and vertical button are held. Had to use MATH to do so: squared the original maxSpeed and then doubled it to get maxSqr - then took the square root of that and halved it to get the newMaxSpeed, which I used instead. Classic A2 + B2 = C2, but since it's being added on twice (once each for both horizontal and vertical) I had to halve it. MATH!

TooMuchAbstraction posted:

You might find this talk to be useful. It goes over how one of the Wolfire devs set up their character controller. It's from the standpoint of needing to animate the thing, but I'd bet there's some useful info in there anyway.

Thank you!

This was a great watch, thanks!

KillHour
Oct 28, 2007


Instead of doing a screen space cloud image for transparency, I would do a flickering effect. Another thing you could try that should be doable and look really cool (although probably a lot of work) is to use the depth buffer as an input to a refraction shader to make it look like it's distorting the background.

Doc Block
Apr 15, 2003
Fun Shoe
Right now it just looks like the ship is partly submerged. Maybe make the cloud texture smaller/finer so the ghost effect is more detailed and obvious.

jizzy sillage
Aug 13, 2006

CodfishCartographer posted:

Wound up solving my normalization problem: I simply reduced the max speed when both a horizontal and vertical button are held. Had to use MATH to do so: squared the original maxSpeed and then doubled it to get maxSqr - then took the square root of that and halved it to get the newMaxSpeed, which I used instead. Classic A2 + B2 = C2, but since it's being added on twice (once each for both horizontal and vertical) I had to halve it. MATH!

This was a great watch, thanks!

You could have just normalized your input, right?

code:
Vector2 input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")).normalized;
Gamepad inputs from sticks tend to come already normalized (or near enough) so if you have gamepad support you won't run into weird issues with your normalized max speed being applied to a normalized input.

D34THROW
Jan 29, 2012

RETAIL RETAIL LISTEN TO ME BITCH ABOUT RETAIL
:rant:
Is there a game development thread for traditional games that anyone knows about? I'm starting my first real foray into honest game design in a decade and it's starting as a TCG that I plan to computerize.

Xerophyte
Mar 17, 2008

This space intentionally left blank

D34THROW posted:

Is there a game development thread for traditional games that anyone knows about? I'm starting my first real foray into honest game design in a decade and it's starting as a TCG that I plan to computerize.

Trad Games has a design and publishing thread: https://forums.somethingawful.com/showthread.php?threadid=3909179

CodfishCartographer
Feb 23, 2010

Gadus Maprocephalus

Pillbug

jizzy sillage posted:

You could have just normalized your input, right?

code:
Vector2 input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")).normalized;
Gamepad inputs from sticks tend to come already normalized (or near enough) so if you have gamepad support you won't run into weird issues with your normalized max speed being applied to a normalized input.

My actual input values aren't actually being used to scale the movement speed, so unfortunately I don't think that would work. They're just being used as bools to determine if they're being pressed, and then the scaling of the movement speed is done manually so I have full control over how much is scaled per frame.

D34THROW posted:

Is there a game development thread for traditional games that anyone knows about? I'm starting my first real foray into honest game design in a decade and it's starting as a TCG that I plan to computerize.

There's also a board game design thread. It's a bit slow but great for shooting around ideas and talking about design and production, and there are a few goons that frequent it that have had games successfully published:

https://forums.somethingawful.com/showthread.php?threadid=3518654&pagenumber=80&perpage=40

CodfishCartographer fucked around with this message at 18:07 on Oct 3, 2021

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
I am getting really pissed at Steam support. So, backstory: my bank did a big transition on August 31st / September 1st, which included changing which routing number to use to send money to the bank. Naturally, I gave the "wrong" information to Steam, so when they tried to pay me, the payment failed. I filed a ticket, requesting a) that my payment details (which were accurate by this point in time) be corrected, and b) that Steam attempt payment again. I got a response of "sorry, we only make 1 payment per month". My account details did get flagged as "administrator review" or something like that, which I rashly assumed meant that Steam was taking a look at them.

Cue late September: I get an email from Steam saying "your account details are invalid, you need to fix them". So again I file a ticket. This time the support person actually marks my details as correct...but, naturally, "we only make 1 payment per month". Even though they haven't actually tried to pay me.

My game launched in mid-loving-August and I haven't been paid 1 cent for it yet :mad:

I'm still trying to bring the support person around, but I'm also really goddamn close to just laying this all out on Twitter.

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug
I'm working on a 3rd person cover system in Unity (C#) using the new Input System. I want to imitate MGS1 behavior where if the player stops pressing the stick towards cover the character exits cover. I feel like I need to turn my movement direction (represented by a Vector2 from the Input System) into a Vector3 and then modify it so its values relative to the players forward Vector but I'm not sure how. Is transforming my input to be relative to player.forward the right approach, and if so what's the basic math look like?

got it, something like this:

code:
var e = Camera.main.transform.rotation.eulerAngles;
e.Set(0f, e.y, 0f);
var m = Quaternion.Euler(e) * new Vector3(input.x, 0f, input.y);
var d = Vector3.Dot(transform.forward, m);

if (d >= 0)
    ExitCover();
edit to add: In order to ape MGS1 and repeatably take cover, it doesn't seem like Unity's collision detection is going to do the job. After leaving cover, i have to move a short distance from cover to re-trigger collision+cover. While in cover, I already use a linecast to detect the edge of cover. I'm thinking a short linecast to test for nearby cover be would let me quickly enter/exit cover. Does that seem right?

Dr. Poz fucked around with this message at 02:12 on Oct 4, 2021

jizzy sillage
Aug 13, 2006

Yeah if you're using OnCollisionEnter it can't retrigger on the same object until it's done OnCollisionExit, so I'd manually linecast. Manually linecasting means you could also do it 10/20 times a second instead of on Update/FixedUpdate (if performance is an issue).

Mr Shiny Pants
Nov 12, 2012

TooMuchAbstraction posted:

I am getting really pissed at Steam support. So, backstory: my bank did a big transition on August 31st / September 1st, which included changing which routing number to use to send money to the bank. Naturally, I gave the "wrong" information to Steam, so when they tried to pay me, the payment failed. I filed a ticket, requesting a) that my payment details (which were accurate by this point in time) be corrected, and b) that Steam attempt payment again. I got a response of "sorry, we only make 1 payment per month". My account details did get flagged as "administrator review" or something like that, which I rashly assumed meant that Steam was taking a look at them.

Cue late September: I get an email from Steam saying "your account details are invalid, you need to fix them". So again I file a ticket. This time the support person actually marks my details as correct...but, naturally, "we only make 1 payment per month". Even though they haven't actually tried to pay me.

My game launched in mid-loving-August and I haven't been paid 1 cent for it yet :mad:

I'm still trying to bring the support person around, but I'm also really goddamn close to just laying this all out on Twitter.

Welcome to the "platform economy". It sucks, count your blessings that actually talked to a person.
I hope it works out.

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug
I have the old Beginning Physics & Math for Game Programmers book but its 20+ years old now and I'm still poo poo at knowing when its time to use things like Dot/Cross product. Is there a more modern reference with less need for errata?

Peanut Butler
Jul 25, 2003



working on a game-adjacent project in python intended to be able to run snappily enough on old/cheap ~1GHz/GB systems-

sketching out the functions, I'm passing a lot of lists around with a lil bit of sanity checking to make sure the values are as expected- one common format is a list of three integers that represent the XdY+N dice rolling format- thinking as I flesh this out, that I should be shifting to using dicts for things like that- is that going to have a significant impact on performance?

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

Peanut Butler posted:

working on a game-adjacent project in python intended to be able to run snappily enough on old/cheap ~1GHz/GB systems-

sketching out the functions, I'm passing a lot of lists around with a lil bit of sanity checking to make sure the values are as expected- one common format is a list of three integers that represent the XdY+N dice rolling format- thinking as I flesh this out, that I should be shifting to using dicts for things like that- is that going to have a significant impact on performance?

Are you familiar with dataclasses? They fit these situations really well.

https://www.python.org/dev/peps/pep-0557/

e: and defining __slots__ on dataclasses can speed them beyond raw dicts.

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

Mr Shiny Pants posted:

Welcome to the "platform economy". It sucks, count your blessings that actually talked to a person.
I hope it works out.

Thanks. I just wish I had some options or more leverage (hence why I'm contemplating throwing a Twitter fit). I guarantee that if I were representing a bigger studio, I'd be getting better support for this kind of thing. But I'm sure Steam looks at my numbers and thinks "ahh, this guy is small time, no need to engage higher-tier support and actually do anything beyond the barest of bare minimums." Never mind that they're holding thousands of my dollars hostage just because they can't be arsed to make an out-of-band payment.

12 rats tied together
Sep 7, 2006

In terms of performance, lists are going to be faster and cheaper than dictionaries here unless your XdY+N data is not* sorted consistently. Tuples will be cheaper to store than lists, but not by a lot, and they're immutable which could be bad.

Maybe stupidly, string index is fairly well optimized in python (most python collections are untyped, which means that finding the "next" item is expensive compared to just looking at (memory address of previous item + fixed size of item)), so the string "2d6+1" might be faster than any dynamic collection as long as you only need to extract a single character at a time and you don't need to cast that character to something else.

I'd probably recommend going either dataclass for readability, or if you're going to sacrifice readability for performance, use a typed array: https://docs.python.org/3/library/array.html. You'll probably want to create a signed integer array so you can put negative numbers in there, for e.g. 2d6-1.

12 rats tied together fucked around with this message at 18:06 on Oct 4, 2021

D34THROW
Jan 29, 2012

RETAIL RETAIL LISTEN TO ME BITCH ABOUT RETAIL
:rant:
I didn't even think of using lists or tuples; last time I was parsing a dice roll, I passed it as "XdY+N" as a string, splitting on "d" and then splitting again on "+" or "-", similar to:

12 rats tied together posted:

Maybe stupidly, string index is fairly well optimized in python (most python collections are untyped, which means that finding the "next" item is expensive compared to just looking at (memory address of previous item + fixed size of item)), so the string "2d6+1" might be faster than any dynamic collection as long as you only need to extract a single character at a time and you don't need to cast that character to something else.

I imagine, in such a situation where you're, say, reading something from a database where the "dice" field contains an "XdY" formatted item, plus "modifier" field of the format "+/-N", the string method (or even a dice_roll(num_sides: int, modifer: int = 0) method might be handy.

bobthenameless
Jun 20, 2005

Dr. Poz posted:

I have the old Beginning Physics & Math for Game Programmers book but its 20+ years old now and I'm still poo poo at knowing when its time to use things like Dot/Cross product. Is there a more modern reference with less need for errata?

I've had (amazon) Mathematics for 3D Game Programming and Computer Graphics and have found it to be fairly solid, but I'm not sure on the errata. I have some problems with it, but a few other more general math texts helped with that. The cover is not one of them, imo.

giogadi
Oct 27, 2009

I recommend gamemath.com

It’s free, well written, and keeps everything focused and motivated for video games.

xgalaxy
Jan 27, 2004
i write code

bobthenameless posted:

I've had (amazon) Mathematics for 3D Game Programming and Computer Graphics and have found it to be fairly solid, but I'm not sure on the errata. I have some problems with it, but a few other more general math texts helped with that. The cover is not one of them, imo.

That author has an updated book:
https://www.amazon.com/Foundations-Game-Engine-Development-Mathematics/dp/0985811749

Kaedric
Sep 5, 2000

Have an issue that I could use some advice on. The idea is you're in a spaceship that eventually can move very quickly with constantly applied acceleration. I want to be able to control a throttle manually with an actual physical throttle in the ship. This is easily done with built-in hinges/joints etc on physics objects.

The problem is that when the ship moves fast enough, the handle for the throttle freaks out and essentially flies off, presumably because physics is being applied to it. There are multiple solutions for this that I was mulling over and i'm curious what you folks think.

Option 1 would be to not use any built-ins, and just have an object 'manually' moved by the player through direct code. This is likely the route I'd go due to its simplicity, but it annoys me having to reinvent the wheel for some very basic objects.

Option 2 would be to have the internals of the spaceship not have physics applied to them, and have what is shown on the 'screen' or front window of the ship simply be a camera view of a different scene. This is ok as long as I never leave the ship, but I don't necessarily want to write myself out of that possibility. I might have to do this anyway though, since stuff moving in space at massive velocities sort of breaks game engines anyway (floating point issues).

Not sure if there's any other way to deal with it.

Adbot
ADBOT LOVES YOU

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
I would do both, honestly. Using physics objects for controls is unlikely to give good user experience even if you didn't have the speed problem. And as you mentioned, having objects moving at high speeds all the time causes floating point issues. You might be able to do a floating origin, where the ship is always at (0,0,0) with zero velocity and everything else moves instead.

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