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
Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I feel like I've hit an X instead of Y inside of an X instead of Y thing here which is going to frustrate me a little bit, but I wanted to talk shop about how much you've decoupled from Unity. I'm still pretty ingrained with GameObjects and MonoBehaviours and don't anticipate as a solo person that I'll start to hit performance burdens with them. If I had a new thing to do then I'd look more intently at ECS. As it stands, a lot of this logic is in subsystems already but I'd have to formalize entities and components. I can try to devise a better example later of something I have where I want to preserve the scheduling.

Adbot
ADBOT LOVES YOU

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 feel like I've hit an X instead of Y inside of an X instead of Y thing here which is going to frustrate me a little bit, but I wanted to talk shop about how much you've decoupled from Unity. I'm still pretty ingrained with GameObjects and MonoBehaviours and don't anticipate as a solo person that I'll start to hit performance burdens with them. If I had a new thing to do then I'd look more intently at ECS. As it stands, a lot of this logic is in subsystems already but I'd have to formalize entities and components. I can try to devise a better example later of something I have where I want to preserve the scheduling.

A lot of my professional work has been writing and maintaining client side caches and display logic for server authoritative thin-client games. Also to a slightly lesser degree maintaining services and databases that store and mutate that data.

Nothing in unity is real. It's all just there to make final vis to the user easier. I generally have to serialize data back and forth as matter of course.

I've done this enough that I've more or less adopted it for my client authoritative hobby stuff as well. Maybe I'll use scriptable objects to house my data instead of excel or json, but I typically just treat it like a database. I've also used sqlite for storing data fairly effectively, though it's not something I'd recommend for data that changes at all frequently.


If you want a small project that demonstrates the workflows pretty well, it's not terribly difficult to build a wrapper around libtcod (grid-based utility library for authoring roguelikes) and ultimately forwarding that to a tile manager/etc to vis the external data in unity.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I trust your judgment on it but I'm also amazed how stuff like that would be considered so superior than Unity's own internals.

I write that knowing I use Noesis for GUI stuff, a 3rd-party A* pathfinding library, and got FMOD for doing sound (since apparently Unity doesn't repeat music tracks seamlessly?).

Okay I guess I shouldn't be surprised.

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 trust your judgment on it but I'm also amazed how stuff like that would be considered so superior than Unity's own internals.

I write that knowing I use Noesis for GUI stuff, a 3rd-party A* pathfinding library, and got FMOD for doing sound (since apparently Unity doesn't repeat music tracks seamlessly?).

Okay I guess I shouldn't be surprised.

I mean.. I use unity UI, mono behaviours etc. It's just all of that stuff is built to handle data that's canonically sourced outside the unity context. Makes tests (play mode and editor) much simpler as a bonus. Just shove data at it.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Are there some external things (text, video, whatever) going over how much people have decoupled from Unity while still using it? This is a common enough mood on here that I assume it gets talked about in detail elsewhere. I wanted to see some of the different experiences.

Regarding my scheduling thing: I take it there isn't some thing people are all using other than leaning on Tasks as much as possible. This is without considering how I save level state.

FuzzySlippers
Feb 6, 2009

You pick and choose your Unity systems. Unity systems might be avoided because they become difficult to debug in complex situations, its awkward to manage their data at scale, or they have pointless overhead. There's no reason to reduplicate a Unity system when it works well. Like I had my own sprite system when Unity's sucked, but I got rid of it when Unity improved it. The new input system I also thought was good enough to ditch any third party assets. I still use my own sprite animation system because I think Unity's has far too much complexity, awkwardness, and performance overhead for the usual fairly simple requirements of sprite animation. When used endemically for something simple like UI animation it has unexpected performance impacts.

Some systems just suck so whatever you gin up is potentially better and at least you know them inside and out. I'm not actually very fond of most third party assets because its another cook in the kitchen for something you also don't know through and through. There are exceptions though like Mecanim sucks forever in all situations and if you need to do 3D animation I highly recommend Animancer. Addressables is dreadful and not getting better and this is far better.

For gameobjects I just find them awkward to deal with, manage their memory, or debug compared to plain c# objects. I think they should only be used when it's necessary because something needs to interact with Unity built in systems like colliders, renderers, etc. Their overhead is minimal but its also part of the thousand shrugs that lead to a Unity mess that runs poorly. Early optimization is bad but no reason for unnecessary bloat either. Like I use their sprite system but don't do sprite prefabs. It was easier to have a generic sprite renderer prefab that can be attached to an entity that needs to render a sprite. When done I can pool the Unity sprite renderer and more easily manage the memory of the actual sprites. Hot references in prefabs can be a mess for memory management.

edit: Unfortunately no specific videos/articles come to mind. If you focus on talks or articles from actual commercial games using Unity you'll find lots of info on bypassing messy Unity systems. I can't think of specifics but a lot of GDC talks from Unity game devs are basically about how they rewrote some Unity thing to solve a problem. Its also a common topic at any programmer bullshitting sessions at conferences/whatever.

FuzzySlippers fucked around with this message at 00:44 on Apr 8, 2021

Ireland Sucks
May 16, 2004

Hi - Graphics question that's driving me out of my loving mind, I'm porting a graph rendering thing from OpenGL to Vulkan and this is the only thing I can't get working after bashing my head against it for days.

Here is Mr Cube, who is going to demonstrate the problem.



If I change the rotation on the Y axis, it rotates on the Y axis:



Cool. Let's reset the Y axis back to zero and now rotate it on the X axis.



Yep. That's nice. Now, what I want to happen is that, when rotated on one axis, it rotates the way pictured - regardless of the current rotation on the other axis.

Here is the relevant code I'm using (library called Veldrid in C#, but I think this is just generic Vulkan) - adapted from this

code:
            Matrix4x4 projection = Matrix4x4.CreatePerspectiveFieldOfView(1.0f, (float)Window.Width / Window.Height, 0.5f, 100f);

            Matrix4x4 pitch = Matrix4x4.CreateFromAxisAngle(Vector3.UnitX, _pitch);
            Matrix4x4 yaw = Matrix4x4.CreateFromAxisAngle(Vector3.UnitY, _yaw);

            Matrix4x4 rotation = yaw * pitch;    // <------------- rotate by the angles

            Matrix4x4 translation = Matrix4x4.CreateLookAt(Vector3.UnitZ * 2.5f, Vector3.Zero, Vector3.UnitY); //<------- move the camera back a bit so we can see it

            Matrix4x4 view = rotation  * translation * projection;

            _cl.UpdateBuffer(_viewBuffer, 0, view);
Now the problem is that when I rotate it on the X axis, the Y rotation turns into Z axis rotation instead



So, graphics wizards vaguely competent people, how can I make this happen? I think what I'm looking for is "Camera-Relative Orientation" or possibly an arcball camera (though i'd rather rotate the model as it less complex to add camera movement later) but none of the code examples i've tried works and I get lost long winded graphics math guides. The most common suggestion i've seen is to change the order of multiplication (rotation = pitch * yaw) but that just flips the problem so Y rotation is always fine but X axis rotation goes bad instead. I vaguely remember that you could do this in OpenGL by pushing the matrix for each rotation.

Thanks!

Phigs
Jan 23, 2019

That looks like gimbal lock. It's basically a limitation of euler rotation, you can see how it works here: https://www.youtube.com/watch?v=zc8b2Jo7mno

I believe the typical solution is to use quaternion rotation instead. I'm not very experienced with this kind of thing though. There might be a way to detect the problem and switch the order of x/y/z dynamically as needed.

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!
I think doing the multiplication in the right order is the right solution for what you described. But I think your description of the problem may not be actually what you want.

If you rotate on X by an amount and then want rotating on Y to be around the other axis, then doing it in the right order will solve it. But if you then want to be able to rotate on X again and have that be around the absolute X axis again, then updating the X "angle" in your fixed-order code won't help you because that angle is the angle that is rotated before the Y angle, so it'll do the wrong thing.

The solution you're looking for if that's what you're trying to do is that you can't do it with just two angles - you have to keep a copy of the current *combined* rotation, and apply your new additive rotation around the absolute axis as a multiplication onto that combined angle.

Because floating point math isn't precise, if you do it this way you also have to occasionally normalize the stored rotation matrix or it will gradually begin to deform your object as the imprecisions propagate over time.

Jewel
May 2, 2009

Not sure since I haven't done it in a while, but I think you want to rotate around the camera's axis, not the world axis. Y axis rotation is spinning the object around "horizontally" to you, so if you shift X axis up 90 degrees to look from above, you're still spinning it around the same axis, so it just spins like the last diagram.

Building a rotation like that from scratch is tricky because the way you want to rotate depends on the way you're Currently looking, so I'd do it more as applying adjustments over time to a stored rotation matrix, and taking your current camera's facing angle to calculate which vector to spin around.

code:
Matrix4x4 projection = Matrix4x4.CreatePerspectiveFieldOfView(1.0f, (float)Window.Width / Window.Height, 0.5f, 100f);

Vector3 camera_up = Vector3.Transform(Vector3.UnitY, _storedRotationMatrix);
Vector3 camera_right = Vector3.Transform(Vector3.UnitX, _storedRotationMatrix);

// Note, _pitch and _yaw should be delta values with this approach, desired pitch minus old pitch and same for yaw -- 0 for "stay where you are"
Matrix4x4 pitch = Matrix4x4.CreateFromAxisAngle(camera_right, _pitch);
Matrix4x4 yaw = Matrix4x4.CreateFromAxisAngle(camera_up, _yaw);

Matrix4x4 offset_rotation = yaw * pitch;    // <------------- rotate by the angles
Matrix4x4 rotation = _storedRotationMatrix * offset_rotation; // <-- Get a matrix that's your current one rotated by a little (unsure if this is the right order, may have to reverse)

Matrix4x4 translation = Matrix4x4.CreateLookAt(Vector3.UnitZ * 2.5f, Vector3.Zero, Vector3.UnitY); //<------- move the camera back a bit so we can see it

Matrix4x4 view = rotation  * translation * projection;

_cl.UpdateBuffer(_viewBuffer, 0, view);

_storedRotationMatrix = rotation;
Edit: ^ Yeah what they said

Ireland Sucks
May 16, 2004

That works perfectly, thank you so much! Would not have thought to do it like that.

Zaphod42
Sep 13, 2012

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

roomforthetuna posted:

Because floating point math isn't precise, if you do it this way you also have to occasionally normalize the stored rotation matrix or it will gradually begin to deform your object as the imprecisions propagate over time.

I wrote a 3D Tetris program in college and I found this out when I kept rotating blocks and they'd start warping after several rotations :allears:

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Zaphod42 posted:

I wrote a 3D Tetris program in college and I found this out when I kept rotating blocks and they'd start warping after several rotations :allears:
I hope there is a corresponding bug where they randomly get caught on the corners of blocks when you try to drop them because of some 0.0001-unit overlap in the collision.

Zaphod42
Sep 13, 2012

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

OneEightHundred posted:

I hope there is a corresponding bug where they randomly get caught on the corners of blocks when you try to drop them because of some 0.0001-unit overlap in the collision.

Sadly the code that checked for where blocks would land was purely 2D, it was just rendering that as a 3D representation. That sounds like an interesting (and extremely un-fun lol) mechanic though.

Lowen
Mar 16, 2007

Adorable.

Zaphod42 posted:

Sadly the code that checked for where blocks would land was purely 2D, it was just rendering that as a 3D representation. That sounds like an interesting (and extremely un-fun lol) mechanic though.

https://aslangames.itch.io/tetris-with-physics

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
What are people generally doing for bounds checking for their overall game world or level? I started to work on this, and with adding on diagnostic stuff, it's starting to get a little wild. There's determining what the bounding volume is at a given time, whether it's even active, and what to do when stuff runs into it. I'm using a box collider in Unity and have a specific MonoBehaviour wrapped around trigger exit callbacks to catch the culprits. Then how I react is kind of varying on what I hit.

I'm trying to think about what to do if a player hits the volume, and I'm just defaulting to killing them.

Zaphod42
Sep 13, 2012

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

Rocko Bonaparte posted:

What are people generally doing for bounds checking for their overall game world or level? I started to work on this, and with adding on diagnostic stuff, it's starting to get a little wild. There's determining what the bounding volume is at a given time, whether it's even active, and what to do when stuff runs into it. I'm using a box collider in Unity and have a specific MonoBehaviour wrapped around trigger exit callbacks to catch the culprits. Then how I react is kind of varying on what I hit.

I'm trying to think about what to do if a player hits the volume, and I'm just defaulting to killing them.

A kill plane is pretty common in videogames, (implemented either as a box, plane, or just a line of code that checks "if coord Y ever < X kill player") so that's certainly a solution :shrug:

It kinda depends upon the nature of the game, genre, how easy it is or how likely it is to encounter the bounding volume.

Fuschia tude
Dec 26, 2004

THUNDERDOME LOSER 2019

Rocko Bonaparte posted:

I'm trying to think about what to do if a player hits the volume, and I'm just defaulting to killing them.

Other common solutions are just bouncing the player off elastically, or setting their velocity to 0.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Having the player killed like that gave my complete game loop a little bit of stress, and it failed.

I guess this is yet more cautionary tales about putting too much logic into Unity's MonoBehaviour stuff. My entire game was being controlled by a MonoBehaviour that did all player navigation as well as main menu navigation. When the player dies, they eventually get deleted. When they get deleted, the MonoBehaviour is destroyed. Then I lose all control of anything.

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:

Having the player killed like that gave my complete game loop a little bit of stress, and it failed.

I guess this is yet more cautionary tales about putting too much logic into Unity's MonoBehaviour stuff. My entire game was being controlled by a MonoBehaviour that did all player navigation as well as main menu navigation. When the player dies, they eventually get deleted. When they get deleted, the MonoBehaviour is destroyed. Then I lose all control of anything.

Yes, you should maintain separation of concerns. Especially on systems with separate lifecycles.

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
Also remember that just because something dies, that doesn't mean you have to Destroy it. You can move it out of the way, shut down irrelevant tasks it might be executing, and keep the object around for later. This is a basic aspect of pooling objects, which is something many games need in order to be performant.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.
Yeah that's not a monobehavior problem per se.

Definitely an issue to think about though.

ButtWolf
Dec 30, 2004

by Jeffrey of YOSPOS
Unity help please.

Camera won't render depth stuff from shader graph. Left is viewport, lil one is in game

Reharakhti
Oct 9, 2012

Secretly Sekhmet

Did you turn on the Depth texture in the renderer settings?

ButtWolf
Dec 30, 2004

by Jeffrey of YOSPOS

Reharakhti posted:


Did you turn on the Depth texture in the renderer settings?

Yup. Thanks.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
I've been dabbling in Love2D and then eventually decided to try out this book:

https://howtomakeanrpg.com/

Which uses Lua and DinoDeck. I know it's not something that will get me ajywheres but that's fine since this is just a hobby. Anyways, I'm wondering if any of you know a site where I can buy 2d assets and sprites or hire a artist? I looked on the unity asset store but everything seems very of a certain mobile game style, if that makes sense.

Thanks for your help!

big scary monsters
Sep 2, 2011

-~Skullwave~-
Humble Bundle has 2D game asset packs pretty frequently. They have an RPG oriented thing at the moment, maybe some of it is of use to you.
https://www.humblebundle.com/software/royalty-free-rpg-game-dev-assets-software

a7m2
Jul 9, 2012


Empress Brosephine posted:

I've been dabbling in Love2D and then eventually decided to try out this book:

https://howtomakeanrpg.com/

Which uses Lua and DinoDeck. I know it's not something that will get me ajywheres but that's fine since this is just a hobby. Anyways, I'm wondering if any of you know a site where I can buy 2d assets and sprites or hire a artist? I looked on the unity asset store but everything seems very of a certain mobile game style, if that makes sense.

Thanks for your help!

itch.io has a fair amount of assets and humble bundle does bundles every now and then, like right now

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
oh sweet thank you both so much

MikeJF
Dec 20, 2003




Those packs on Humble tend to link back to gamedevmarket, that's another place you could browse.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.
Yeah I got half my art assets by buying a humble bundle and then following the artists who made things in the bundle back to the unity marketplace or other art marketplaces and bought more of their stuff.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
Yeah I found someone doing the exact style I want on gamedevmaker so I'm going to reach out to them. It's exciting but imho the worst part of making indie games is the art if you have no artistic talent

ButtWolf
Dec 30, 2004

by Jeffrey of YOSPOS
Im in Unity. What would cause less potential problems w/ 20 players?: growing player scale or shrinking everything else?

Metos
Nov 25, 2005

Sup Ladies
Growing the players is less hassle for sure

awesomeolion
Nov 5, 2007

"Hi, I'm awesomeolion."

hello thread, i've been goofing around with Unity ML Kit and making youtube videos capturing the process... I haven't got any cool results yet but i'm enjoying making these videos. So far I've made a basic clone of Ski Free and I'm trying to make an ML agent ski down the slope nicely. Here's a link if you want to check out the latest one: https://www.youtube.com/watch?v=RDmJb_WmzS0. If you want to give feedback/constructive criticism that's cool too :thumbsup:

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
That's a sweet vid, good job.

I should get into Unity, is unity learn the best source to learn Unity if I already know a decent amount of C#? (I used to xna program uh 14 years ago. It's like a bike isn't it ?!?)

Zaphod42
Sep 13, 2012

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

Empress Brosephine posted:

That's a sweet vid, good job.

I should get into Unity, is unity learn the best source to learn Unity if I already know a decent amount of C#? (I used to xna program uh 14 years ago. It's like a bike isn't it ?!?)

Learn.Unity has lots of cool tracks that can walk you through things. I really like Bracheys videos on youtube https://www.youtube.com/user/Brackeys

Its definitely like riding a bike. You'll have to learn a little bit about how to use the editor but it should be pretty easy to jump into :)

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
Sweet thanks zaphod

awesomeolion
Nov 5, 2007

"Hi, I'm awesomeolion."

Empress Brosephine posted:

That's a sweet vid, good job.

I should get into Unity, is unity learn the best source to learn Unity if I already know a decent amount of C#? (I used to xna program uh 14 years ago. It's like a bike isn't it ?!?)

Thanks! Since Unity is so widely used, one option is to just start making something you want to make and Google as needed. Any problem you're trying to solve should pop up on Google if you can get close to describing it

Adbot
ADBOT LOVES YOU

Surprise T Rex
Apr 9, 2008

Dinosaur Gum
The one thing I get stuck on with Unity is coming from a software dev job, I get caught up trying to build a game like an enterprise app and tbh it's much better when doing small projects to just do whatever and worry about cleaning it up later.

To an extent, anyway. Just hide the garbage stuff behind a nice method name and pretend it doesn't exist.

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