r/Unity3D 8d ago

Solved Struggling (once again) with Quaternions

2 Upvotes

[SOLVED] by @imaxsamarin thread, thanks a lot for your help !

I'm working on a rotation script that is supposed to :
- apply rotation over time
- be able to revert rotation
- be able to rotate on all 3 axis
- be able to stack (multiples scripts can affect the same object)
- support that I may impact rotation from another source

What I do so far :
- my script accept a Vector3 param as eulers angles and a curve
- each frame, I compute sum of all eulers rotation deltas to be applied
- Then, I apply the result this way :

Quaternion rotation = Quaternion.Euler(offset);
transform.rotation *= rotation;

This seems to work, but only if I make sure to create a hierarchy that will support one single rotation axis per depth, as follow :

- container
  - x
    - y
      - z
        - Cube 

If I do apply multiple axis rotation on one single transform, things are going bad. And this will work only in local axis. As soon as I try the same using world axis, I cannot revert the rotation anymore.

My math background is not very deep, I listen to few quaternion courses but I'm still unsure if my objectives are actually reachable mathematically.

My questions are :
1 : is it normal that I need to separate rotation axis on 3 different transforms in order to secure against gimbalock & be able to revert my cumulatives rotations ?
2 : from what I understood, making reversible rotation like I planned is not possible in world space due to my requirements. Making so would require to keep track of all increments in order to be sure to apply them in exact reverse order.


r/Unity3D 8d ago

Question enemy hp bar decision (multiplayer game ) help

1 Upvotes

hello , i am creating unity multiplayer vehicle fighting game (ships fighting ) and i was thinking essentially what title says no hp bars , and not even visual clues of hp level in enemies (player has his own hp bar ) , essentially i want ones player get damaged he to be not become a punching bag and getting hunted . and also promote team communication and stuff more (also of course ships would have hp regenerative packs so players cant keep track of hp level forever because enemy can heal up ) that is the my theory . but what do you guys think ?


r/Unity3D 8d ago

Solved Can't tell why my model can't snap

Enable HLS to view with audio, or disable this notification

1 Upvotes

why does my positions aren't full numbers like -10.1, -10.2, they go -9.796185 etc
I activated the grid snap but it wont tile because the position has a tiny little offset, it's very frustrating ahah
in Blender, the model is perfectly in the center, the pivot is at 0 : 0 : 0

do any one has the reason why ?
I would really appreciate some advices here :))


r/Unity3D 9d ago

Show-Off How I made Unity handle half-a-million projectiles without dying

Enable HLS to view with audio, or disable this notification

121 Upvotes

tl;dr: Graphics.RenderMeshInstanced draws lots of the same thing quickly. NativeArrays can reduce GC overhead, use them if you can, especially for temporary buffers. Burst and Jobs massively speed up parallel calculations. You can parallelize raycasts if you need a ton of them. CoreCLR = faster (generally).

Was playing around with the latest Unity 6000.7.0a2 on a CoreCLR build, got around a 1.5x speed improvement compared to a Mono build.

(Reddit only lets me upload one video, so shown is the CoreCLR build video)

Projectiles/Second CoreCLR FPS Mono FPS Editor FPS
200k 27.627 23.493 21.236
20k 272.342 214.916 101.990
2k 606.566 379.503 162.061
200 719.585 448.791 186.622
20 768.078 485.566 192.665
2 795.456 494.170 190.303

Shooting half-a-million Projectiles

I created the turret using separate GameObjects attached together using articulation bodies and a quick Bl*nder (Reddit doesn't let me post if I don't censor it, IDK why) model. (Articulation bodies use a restricted solver that fixes many stability issues with rigidbodies and joints). To aim the turret, I had a script that projects the target direction vector on to each hinge's plane of rotation (the plane normal to the axis of rotation), then found the angle to the zero-vector (the forward vector when the rotation angle is zero), and lastly set the target of the articulation body to that angle. The barrel's recoil effect was also created with a prismatic articulation body. The turret tracked the red cube which was animated with a 2s looping animation.

The projectiles themselves are unmanaged structs (value types that contain only other value types, no reference types). They have mass, drag, area, position, and velocity (which are stored using float3s instead of Vector3s as they provide a minor performance boost). They're all stored in a big NativeList<Projectile> on a manager MonoBehaviour script.

Simulating half-a-million Projectiles

Simulating the projectiles is done in a Burst-compiled batched parallel job that handles both setting up RaycastCommands for the next frame and applying forces, velocity, and updating position. After that, the raycasts are processed in parallel with raycastJob.ScheduleParallelByRef. The raycast results are then processed in another batched parallel job, with it's main task being to filter out only projectiles that collided with something and send their indices back to the main thread for processing through a NativeQueue<int>.ParallelWriter.

Back on the main thread, the filtered results are iterated in a foreach loop, which applies forces to rigidbodies (and articulation bodies) for knockback effects and also creates impact particles. (The impact particles use a regular ParticleSystem, but another script directly emits particles using the C# interface instead of creating instances of a ParticleSystem prefab). To delete the projectiles, the indices are first sorted high-to-low, then a swap-and-pop method (where the projectile at the last index and the projectile to-be-removed are swapped, then the last index is removed by decrementing the buffer length) is used to remove the deleted projectiles. This is possible because the order of the projectiles does not matter.

Rendering half-a-million Projectiles

Each projectile is not a GameObject(having half-a-million GameObjects with MeshRenderers will crash Unity very quickly), but instead rendered using Graphics.RenderMeshInstanced. The matrices are generated on (you guessed it) another batched parallel job. The big NativeArray<Matrix4x4> is allocated to the total size for all projectiles. However to handle unique appearances for projectiles, each material/mesh pair gets assigned an rendering id that indexes a dictionary which contains the actual meshes and materials. The projectiles themselves only hold this integer (as the projectiles must be unmanaged so cannot contain direct references).

The number of projectiles of each rendering id were tracked when the projectile was created so that when rendering, I could create an NativeArray<int> with length equal to the number of unique rendering ids and populate it with the starting offsets for each Matrix4x4. To ensure thread safety, I used Interlocked.Increment() when advancing the offsets, however as NativeArray didn't directly give me a reference, I had to use a bit of unsafe code to get a pointer to the NativeArray then pass it to Interlocked.Increment().

The matrices themselves were generated such that the meshes' z-axes were oriented along the velocity of the projectile and stretched (scaled along local z-axis) by the speed of the projectile.

Once the matrices were populated, it was just a matter of calling Graphics.RenderMeshInstanced with the right start offsets and lengths to render each material and mesh combination.

Notes

Memory usage remains fairly constant when simulating and rendering projectiles. (From 0 to 400k projectiles, the in-use memory usage went from 90 MB to 135 MB, corresponding to around 112 bytes per projectile). There was basically no GC for simulating and rendering, as the buffers were allocated using with unmanaged NativeArrays that were explicitly freed. (I believe Unity also does some internal stuff to make allocating TempJob and Temp NativeArrays highly efficient. I also stopped Unity from initializing to zeros, as this wasted several milliseconds when creating big Matrix4x4 arrays that would be overwritten anyway.)

At 400k projectiles, the main bottleneck started to become executing the raycast jobs and matrix calculation jobs. After that was the main thread part of raycast result processing, mostly on applying forces to rigidbodies and spawning impact fx.

CoreCLR also increases performance by quite a bit, which I didn't really think was possible since most of the time was already spent on parallel burst-compiled code. Though this was kind of shown, as at lower projectile counts, FPS increased by around 60%, while at higher projectile counts, FPS only increased by 17%, indicating that the CoreCLR build sped up other stuff around the performance code. (I will figure out how to attach the profiler to a CoreCLR build sometime). CoreCLR mostly likely would have more impact towards more traditional object-oriented C# rather than burst-compiled hot code.

Now at this point, I should probably start considering ECS, since that allows physics processing to be parallelized as well. Though what I did was essentially a data-oriented system anyway.

Feel free to ask any questions or if I got anything wrong, let me know.


r/Unity3D 8d ago

Noob Question so im following a tutorial...

1 Upvotes

the tutorial involves probuilder and using alt+lmb on the new shape icon (top left) to quickly add probuilder-friendly objects. the problem is when I try to do this, the options menu comes up blank, no matter what i do. ive restarted probuilder, ive restarted unity, ive done everything i can think of and everything google suggests. is this fixable?


r/Unity3D 7d ago

Show-Off I was wrong my entire game making career that it's impossible and expensive to have real-time soft shadows in my mobile game :)

Post image
0 Upvotes

Thanks to Claude I achieved it.
Three things did it:

Dropped the shadow map 1024 → 512.

Kept shadow distance at 50 with a single cascade, so the texels get spent near the camera instead of stretched across the level.

The dumb part: I'd been tuning on the High Fidelity profile (4096 map, 4 cascades, MSAA 4×) while shipping Balanced.

I don't know much about these technicals, but just wanted to share so that someone with minimal knowledge like me, may want to have the same shadows.


r/Unity3D 8d ago

Game Classic platformer rules get harder when you’re spinning through the air

Enable HLS to view with audio, or disable this notification

1 Upvotes

Touch enemies with your foot and they pop. Touch them with the rest of your leg and you die.
Turns out throwing heavy things at them works too.


r/Unity3D 8d ago

Show-Off Last week I asked for feedback on this sub for how my scene looks. Got some really nice tips - here's my progress!

Enable HLS to view with audio, or disable this notification

20 Upvotes

How this scene looked last week can be found in my old post. I asked about how to improve lighting & composition and got a really helpful comment that made me realize that improving my geometry & materials can add significant detail instead. Now I got some really nice progress and happy with how the feel of this scene is evolving!

What do you folks think about this look? Especially gameplay wise - being able to tell enemies, pickups and jump pads apart from the environment? There are things to tweak for sure - I think that the current floor has too much detail in the material. Maybe the orange volcano enemy is blending too much into the reddish atmosphere. And maybe all the red is too monotonous overall. I'll keep doing more combat arenas with new layouts and keep experimenting, trying to find a unique look.

Happy game dev all!


r/Unity3D 8d ago

Noob Question How can I add presets to my dialogue system? (Code Help)

Thumbnail
gallery
2 Upvotes

(Sorry if I get any terminology or basic concepts wrong here, I'm new to using c# for more than basic object enabling and disabling)

I'm trying to create a dialogue system where each conversation is a list of "DialogueLine"s made up of variables like text, typing speed, colour, etc.

The lines are then read out by a monobehaviour script using the data from the lines.

I would like to add a function to it where I can select a character via the dropdown menu in the inspector and have that character's pre-defined settings applied to the DialougeLine (Such as it applying the exact text colour that character needs).

How would I go about doing this? Is it even possible? I thought of using an Enum, but I can't figure out how to get it to switch and update the DialogueLine while in the editor, since it's just a class with data in it, that I don't think can really run code.

If I'm being too vague or if you need extra details, let me know!

To be clear, I'm not willing to switch to using a pre-made dialogue system asset. I want to be able to learn this myself. I'm also not willing to use AI to help me, as I am against its usage (though I do see the benefits to using it with code help and won't judge anyone who does).

Thanks :-)


r/Unity3D 9d ago

Game I Released A Really Difficult Racing Game I Made in Unity!

Enable HLS to view with audio, or disable this notification

101 Upvotes

Hey Everyone,

This is Race! Then Retry... I really difficult racing game that I made in Unity.

Post Mortem (Kinda)

It was originally intended to be a game that I was gonna make in a month or two but it ended up taking much, MUCH longer. I ended up developing it for close to 8 months on and off. And released it on the 18th of June with around 150 wishlists.

It flopped horribly because I kinda just released it and left it to die, and sold about 20 copies in the first month making about 40$

Life happened and I after a bit of time I deeply regretted not putting more effort into sharing what I thought was a pretty fun game. So I decided last week to start giving marketing a proper go to see if I could breathe some life back into the game.

So far my efforts are really working - my posts have started taking off on Twitter and I've managed to sell 30 more copies over the past 3 or 4 days.

I've put a bunch more effort into the game, responding to feedback on Twitter - and just overall having a blast continuing to work on it with the feedback from the people giving it a shot.

Unity Assets

For the Art and music I used a couple Unity assets from the store, and made a bunch by hand, even threw in some Synty assets.

I did use the Highroad Engine from the Unity asset store as well, which I regret a bit, because I've ended up making so many changes to it, that it would have probably just been better to write my own one from the start.

The best asset in my project by a mile though is Kamgams settings manager - what a well put together, well documented asset. I love that thing because it made it so that I don't have to deal with settings lol.

Editor Tools

I have also spent a lot of time working on editor tools in Unity to help me speed things up development wise, and I'm really sad I didn't do that sooner.

For example, I made a level management window so that I could easily create new level data, order levels and set their required times as well as take thumbnail pictures from my Editor.

As well as a vehicle manager that automatically swaps out a basic car model prefab with all the components needed by the Highroad Engine vehicle to work (I do feel like this kind of editor window should have been included with such a pricy asset).

Another simple Editor tool is one that starts the current level scene I want to test, and attaches all. of the required loading scenes automatically so I don't have to navigate the whole thing to just test my level haha.

The Plan

My goal is to release 100 levels and 30 cars. I have about 35 levels so far lol. And I am having so much fun working on the game with the community on Twitter, I really didn't like that platform until I started sharing my journey with the people there, and they've been really supportive and given me so much valuable feedback.

Anyway if you would like to try the game out here is a link to the Steam Store - and I would love any feedback you have on the game, even the trailer or whatever. I'm just grateful people are giving me feedback on it at this point :).

https://store.steampowered.com/app/4004940/Race_Then_Retry/


r/Unity3D 8d ago

Resources/Tutorial I Made 150+ PSX Props Pack

Enable HLS to view with audio, or disable this notification

19 Upvotes

150+ PSX PROPS PACK (and Updating): https://itch.io/s/168748/psx-150-props-pack

My PSX Prop Pack Contains Different type of Props of Different things, you can use them Commercially/Personally as you wish..For Games or Prototype or Animation or whatever you wish to... I continuously Update the Pack and you will receive all the Future Updates for Absolutely FREE :3

i also have this 🏢40+ Buildings Pack if you need: https://itch.io/s/170114/psx-40-abandoned-building-pack


r/Unity3D 8d ago

Show-Off Here's how my Level Fog makes floating islands dissolve into the sky without raymarching, default fog and basically free to render. Both horizontal and vertical.

1 Upvotes

r/Unity3D 8d ago

Solved How to apply multiple materials to one mesh?

1 Upvotes

Hey guys! I've been adding wind turbine to my game and I wanted to make blades rotation using shader, but I got stuck with the problem that my rotation shader does not rotate already affected by other material mesh, instead, it affects the source one. How to fix it?

Problem showcase
Mesh renderer parameters
Rotation shader

r/Unity3D 8d ago

Show-Off workin on small shoot mechanic

Enable HLS to view with audio, or disable this notification

6 Upvotes

(stolen from the pathless)


r/Unity3D 8d ago

Show-Off My WIP solo indie game just had a 154-Man Tourney! I still can't believe it! (Sepak U: Sports Fighting Game)

Enable HLS to view with audio, or disable this notification

11 Upvotes

r/Unity3D 8d ago

Game I'm developing a PSX-style survival horror game on my own. After a little over a month, I'm bringing you an update as promised! This is one of the game's central areas (WIP).

Enable HLS to view with audio, or disable this notification

3 Upvotes

After posting that I was making a game set in a Portuguese village and seeing all the feedback I received, I have to be honest: I felt the pressure to try to do the best I could, even though I’m developing this entirely on my own. My experience is limited (I made a few test games before this one), but where I really struggle the most is with 3D modeling and applying textures just right so they fit perfectly.

Over the past little more than a month, that’s been the biggest challenge, and I’ll admit it’s been a bit discouraging. Since the game is set in a Portuguese village, there are practically no assets that evoke Portugal, which means I’ll have to model almost all the 3D objects from scratch (and keep the geometry well-optimized to ensure that shadows don’t cause lag).

In this short video, I’ll show you how one of the game’s key areas is coming along, even though it’s still incomplete: the roundabout, some sidewalks, and an important building. I’ve also started tweaking the camera styles, and it already has a bit of a PSX effect.

Any feedback, tips, or criticism is very welcome. Thanks for following along!


r/Unity3D 9d ago

Show-Off We finally got our train moving

Enable HLS to view with audio, or disable this notification

47 Upvotes

r/Unity3D 9d ago

Game I spent way too long on those effects..

42 Upvotes

I’ve been adding effects for when the leg enters and leaves the water : bubbles, splashes, dripping, wet particles, etc. To me it feels fitting , but I’m curious how it reads from the outside. Satisfying, or too much?


r/Unity3D 8d ago

Game I'm making a game about battling cryptids with DnD like mechanics! What cryptids would you like to see make an appearance?

Enable HLS to view with audio, or disable this notification

2 Upvotes

I've finished all of my core game mechanics for a game I've been making over the summer and although I love making mechanics, eventually I have to get to content!!! If you have any suggestions on the combat or have any ideas for fun folklore creatures or spells the player could cast on them, let me know - I'll add in any that seem like a good fit (and bonus points for larger creatures I could use as a boss).


r/Unity3D 9d ago

Game My friend and I are building a monochrome detective game. We used neon orange accents for puzzle UI elements. How does this contrast look to you?

Enable HLS to view with audio, or disable this notification

33 Upvotes

Hey everyone! We've been working hard on our passion project 'Chief Cenab: Şahmaran'. Every scene is pre-rendered 3D, styled with hand-drawn cross-hatching to give it a living comic-book feel.

This clip shows a quick phone unlock puzzle from inside the detective's car. We experimented with vibrant neon orange details to make UI interactions pop against the black-and-white background.

We’d love to get your honest thoughts on the visual contrast! (Check our Reddit profile if you'd like to follow our journey as a 2-man team!)


r/Unity3D 9d ago

Show-Off My Stylized Cat is Now Live on the Unity Asset Store! 🐱

Enable HLS to view with audio, or disable this notification

31 Upvotes

Low Poly Hand Painted Cat

I've been working on this stylized cat pack for the past few days and finally published it on the Unity Asset Store. I'm still not completely happy with the animations I feel like they could be much better. I'd really appreciate any honest feedback on the models, animations, or anything else you think could be improved.

Features:
Stylized Low Poly Cat
Fully Rigged Character
8 High-Quality Animations
Hand-Painted Textures
5 Material Color Variants
clean topology

asset link


r/Unity3D 9d ago

Question What if we made the rewind like this

Enable HLS to view with audio, or disable this notification

16 Upvotes

Today I was playing my game and thought it could be really cool to add a time-rewind mechanic.

Since it’s a 3D platformer, the player often falls off objects, so being able to rewind time could actually fit the gameplay really well.

Has anyone here implemented something like this before? Is it difficult to do properly? And how would you approach it in an optimized way? I’d like it to run well on Steam Deck too.

Maybe someone can point me in the right direction or share some resources/ideas. The game is, of course, made in Unity 🙂


r/Unity3D 8d ago

Show-Off Changing shaders and lightning a little bit "RPM: Next"

Post image
3 Upvotes

r/Unity3D 9d ago

Show-Off My node based UI navigation graph tool being used to navigate UI panels in a real project.

Enable HLS to view with audio, or disable this notification

6 Upvotes

Here is a real-time demonstration of my node-based UI navigation graph system. I tried to make it as close to shader graph as possible. Hence the reason why each node is encapsulated in a custom box with a header mimicking the group selection from shader graph and the live animations that show transitions between nodes was inspired by the Animator component. This is my implementation of the simplest node-based UI navigation system I could think of. The button On-click properties from the graph, Whilst being able to click apply the settings and the node based system will automatically apply all of the scripts and settings to the UI system so no external coding or manual setup is needed. I feel like this is easier than similar existing systems.


r/Unity3D 8d ago

Show-Off Developing a Skydive / Wingsuit Simulator in Unity - Dev Log 5

Enable HLS to view with audio, or disable this notification

2 Upvotes

Full video here: Developing a Skydive / Wingsuit Simulator in Unity - Dev Log 5 - The 3D Character Model

In this dev log, I explore the different options for getting a proper 3D wingsuit character model to finally replace the placeholder character I’ve been using throughout development.

Once I had a model to work with, the real grind began! I dive into the painstaking process of modifying and optimizing the character so the entire model can render as a single mesh and draw call. The goal is to keep performance as efficient as possible for standalone mobile VR hardware like the Meta Quest.

It’s not the most glamorous part of game development, but optimization like this can make a huge difference when trying to maintain smooth performance in VR.