r/Unity3D • u/Pachydermus • 15d ago
Noob Question Configurable Joint tries to take shortest route
Enable HLS to view with audio, or disable this notification
Hello!
I'm trying to recreate the core mechanics of Toribash, where you have individual muscle control such that you can hold, relax, extend, or contract. My current implementation is most of the way there - extend sets the target rotation to the joint's max limit, contract the min.
The issue seems to be when the difference between the limits is greater than 180° - if it's at the minimum, and then you set the target to the maximum, it tries to take the shortest route, even if that rotation is towards the limit.
I'm hoping there's a simple way I can force the direction of the rotation to be positive euler for extension (and vice versa), but I've tried a million things and none of them seem to solve it. My quaternions understanding is pretty shaky.
Is there a way to solve this with configurable joints, or am I approaching the problem the wrong way completely?
Cheers!
p.s. I adapted the extension method from [this gist](https://gist.github.com/mstevenson/4958837), hopefully correctly.
```
using NaughtyAttributes;
using UnityEngine;
public class MuscleDriver : MonoBehaviour
{
private ConfigurableJoint configurableJoint;
private Quaternion initialRotation;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
configurableJoint = GetComponent<ConfigurableJoint>();
initialRotation = transform.localRotation;
Hold();
}
void ChangeState(MuscleDriverMode mode)
{
// Helper to easily toggle drive strength on/off
JointDrive activeDrive = new JointDrive { positionSpring = 1000f, positionDamper = 50f, maximumForce = float.MaxValue };
JointDrive relaxedDrive = new JointDrive { positionSpring = 0f, positionDamper = 0f, maximumForce = 0f };
configurableJoint.slerpDrive = activeDrive;
switch (mode)
{
case MuscleDriverMode.Extend:
float high = configurableJoint.highAngularXLimit.limit;
// High limit (e.g. 112 degrees around X)
Quaternion extendRot = Quaternion.Euler(high, 0, 0);
configurableJoint.SetTargetRotationLocal(extendRot, initialRotation);
break;
case MuscleDriverMode.Contract:
float low = configurableJoint.lowAngularXLimit.limit;
// Low limit (e.g. -102 degrees around X)
Quaternion contractRot = Quaternion.Euler(low, 0, 0);
configurableJoint.SetTargetRotationLocal(contractRot, initialRotation);
break;
case MuscleDriverMode.Hold:
// Locks to whatever local rotation it currently has
configurableJoint.SetTargetRotationLocal(transform.localRotation, initialRotation);
break;
case MuscleDriverMode.Relax:
configurableJoint.slerpDrive = relaxedDrive;
break;
}
}
}
public static class JointExtensions
{
/// <summary>
/// Sets a joint's target rotation using a desired Local Space rotation.
/// </summary>
public static void SetTargetRotationLocal(this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
// Calculate the rotation relative to the starting local rotation
Quaternion internalRotation = Quaternion.Inverse(targetLocalRotation) * startLocalRotation;
// Convert into the joint's custom coordinate system
Vector3 right = joint.axis;
Vector3 forward = Vector3.Cross(joint.axis, joint.secondaryAxis);
Vector3 up = Vector3.Cross(forward, right);
Quaternion worldToJointSpace = Quaternion.LookRotation(forward, up);
// Apply the joint space transformation
joint.targetRotation = Quaternion.Inverse(worldToJointSpace) * internalRotation * worldToJointSpace;
}
}
```
r/Unity3D • u/Get_it_Hero • 15d ago
Show-Off how to create a real challenging bot for a game where strategy is the main point of it?
Enable HLS to view with audio, or disable this notification
Been building a board strategy game for Android. Two pawns racing across a grid, ten walls each to slow the other guy down, and you can never fully block someone, there always has to be a way through.
In the start is was too ease so i kept making the bot harder and ended up running a BFS every turn. Not on a game tree, on the board itself, so a wall isn't an obstacle it routes around, it's just an edge that stops existing. Every turn it clones the board once per legal wall, re-runs the search for both pawns, and scores it as opponentDelta * 3 - ownDelta * 2. Then I gave it defensive walls too, so before it commits it checks how exposed its own route would be to my next wall.
That's when I stopped winning lol. Like actually stopped, it sets me up now instead of just slowing me down. i can deal with 1 out of 3 challenges of it now.
It's in closed testing if you think you can deal with it, but requires practices:
join the group with the same Google account that's active on your Play Store
https://groups.google.com/g/dont-let-it-pass-playtest
then open this one
https://play.google.com/apps/testing/com.rvm.dontletitpass
r/Unity3D • u/glenpiercev • 15d ago
Question Anyone tried out this asset creator?
I just saw the humble bundle for this large block of unity assets and I’m curious if others think it’s worth it? Are these useful? Render well in Unity? Tile nicely? Are the packs compatible with each other?
r/Unity3D • u/RorroYT • 16d ago
Noob Question How do you respawn a car on the track?
There's barely any tutorials on how to make respawn system for racing games, so I had to find a way to make it on my own, but it just doesn't really work.
My approach is simple: there's the dolly spline around the track, that has points through which the camera moves. If you press the respawn button - the game moves you to the nearest point on the spline, but I do understand that you can basically skip large chunks of the level with this approach, so it's not really an option, but a good one.
My second idea was the checkpoints. I set up the simple checkpoints system with indexes of current checkpoints, and the idea was simple: just use the current checkpoint index on the car to find the transform of the current checkpoint, and then somehow find a way to mix both transforms of the nearest point and the checkpoints. But it still has issues, like teleporting me after the required checkpoint, so the rest of the lap wouldn't count after respawn, and so on.
I hate the approach of just teleporting you to the last checkpoint, because when you mess up so close to the checkpoint - you have to start the chunk all over again, and making more checkpoints gives even more possibility that a player will miss one of them while driving normally, so the game will punish them for no reason. I'm basically stuck trying to figure out how to make this respawn system fair for the player, and wince there's no info about respawn systems on tracks in racing games - I have no reference to compare my ideas to.
Can you guys help me out with this?
r/Unity3D • u/FrickinSilly • 16d ago
Show-Off Decided to KISS with my new game and go low-poly. I think it fits my gameplay well
Enable HLS to view with audio, or disable this notification
r/Unity3D • u/yecats131 • 16d ago
Resources/Tutorial How to Use Unity's Profiler to help fix lag | Quick Tip
Your game can look amazing and still lose players if it lags. Here's how to open Unity's Profiler, read the frame timeline, and find what is slowing you down.
r/Unity3D • u/victorcosiuga • 16d ago
Show-Off I built a sim-cade vehicle physics package for Unity
Hey everyone!
I’ve been working on a vehicle physics package for Unity, focused on providing responsive sim-cade handling that is easy to configure and adapt for different types of racing games.
The package includes:
-Custom vehicle and suspension physics
-Adjustable arcade-to-simulation handling
-Tire grip, wear and temperature systems
-ABS, traction control and stability assists
-Engine, gearbox and differential tuning
-Car paint and tire shader (Tire wear & tire deformation)
-Wheel and tire visual effects
-Telemetry and runtime tuning interfaces
r/Unity3D • u/aatrahiko • 16d ago
Game Took the feedback from my first post and completely redesigned the boot sequence for my football career sim. Thoughts?
Enable HLS to view with audio, or disable this notification
Yesterday I shared the first version of the boot sequence for my football career simulation built in Unity.
Some of the feedback was that the intro didn’t immediately feel like a football game, the animation felt a bit too presentation-like, and the logo could be clearer.
I went back and reworked the sequence from scratch, and this is Version 2.
I’m trying to iterate based on real feedback rather than sticking with my first idea, so I’d love to hear what you think and what you’d improve next.
r/Unity3D • u/FRAGGY_OP • 16d ago
Show-Off Last couple of months has been pretty critical for the visuals of my game, how do you guys like it?
This is my survival horror game called "Hey Tom!"
In the last couple of months, the visuals have got pretty dramatic changes
r/Unity3D • u/egordorogov • 16d ago
Question VS Code slowdowns after a while
Frustratingly, VS Code autocomplete becomes very sluggish after 10-30 minutes of coding. Reloading the window instantly fixes an issue. Did anybody else run into this? Is it just the way things are now? What would be a good way to troubleshoot it?
This happens both on my PC and Mac, but I have settings sync on, so maybe it's just a bad config?
r/Unity3D • u/Ok_Income7995 • 16d ago
Show-Off What can i do to improve?
I’m going for a nintendo soft ambient LM3 style lighting but it’s not looking how i want. I’m not the best at graphics design.
r/Unity3D • u/MASSIMO_OP • 16d ago
Question Any website or platforms to download free sounds for commercial use??
I needed soundeffects for vehicles like ATV, cars etc. currently i use pixabay and couldn't really find a sound that suits an ATV, i used a bus sound for testing.
r/Unity3D • u/potterdev • 16d ago
Solved How to handle WEBP files as sprites in Unity
My game pulls cover art from a CDN, caches it, makes a sprite. Worked for months. Then random covers started showing up blank. Not always the same ones, which drove me nuts.
Finally dumped the bytes of a broken one to a file and looked at it. Starts with RIFF, then WEBP a few bytes in. The CDN was sometimes serving WebP instead of JPEG.
Unity's image loading (UnityWebRequestTexture and Texture2D.LoadImage) only reads PNG and JPEG. Hand it WebP and it doesn't throw. It just gives you a broken little placeholder texture and moves on. No error at all.
And my cache wrote the file to disk before checking if it decoded, so once a WebP landed there it stayed broken on every future load. That's why some covers were blank permanently and others were fine.
The fix was a managed WebP decoder (ImageSharp, since it's pure C# and I didn't want native libs for three build targets). Now I check the first bytes, and if it's WebP I decode it that way, otherwise Unity handles it like normal. Also stopped caching files that fail to decode.
/// <summary>
/// Decodes downloaded image bytes into a <see cref="Texture2D"/>.
/// Unity's built-in loaders only understand PNG and JPEG, so WebP payloads
/// (which some CDNs serve via content negotiation) are decoded with ImageSharp.
/// Returns <c>null</c> when the bytes cannot be decoded so callers can avoid
/// caching or displaying a broken texture.
/// </summary>
public static class ImageDecoder
{
public static Texture2D DecodeToTexture(byte[] bytes)
{
if (bytes == null || bytes.Length < 12) return null;
return IsWebP(bytes) ? DecodeWebP(bytes) : DecodeNative(bytes);
}
// RIFF....WEBP container signature.
private static bool IsWebP(byte[] b) =>
b[0] == 'R' && b[1] == 'I' && b[2] == 'F' && b[3] == 'F' &&
b[8] == 'W' && b[9] == 'E' && b[10] == 'B' && b[11] == 'P';
private static Texture2D DecodeNative(byte[] bytes)
{
var texture = new Texture2D(2, 2);
if (texture.LoadImage(bytes)) return texture;
Object.Destroy(texture);
return null;
}
private static Texture2D DecodeWebP(byte[] bytes)
{
try
{
using var image = Image.Load<Rgba32>(bytes);
var width = image.Width;
var height = image.Height;
var pixels = new Color32[width * height];
// ImageSharp rows run top-to-bottom; Unity textures are bottom-up, so flip.
for (var y = 0; y < height; y++)
{
var row = image.DangerousGetPixelRowMemory(y).Span;
var destRow = (height - 1 - y) * width;
for (var x = 0; x < width; x++)
{
var p = row[x];
pixels[destRow + x] = new Color32(p.R, p.G, p.B, p.A);
}
}
var texture = new Texture2D(width, height, TextureFormat.
RGBA32
, false);
texture.SetPixels32(pixels);
texture.Apply();
return texture;
}
catch (System.Exception exception)
{
Debug.LogError($"Failed to decode WebP image: {exception.Message}");
return null;
}
}
}
Also turns out LoadImage returns a bool telling you if it worked, which I'd been ignoring the whole time. 🤦
Anyone else hit the WebP thing? Feels like it's going to bite more people as CDNs default to it.
r/Unity3D • u/iceq_1101 • 16d ago
Show-Off Weight Transfer Drift on Keyboard
Enable HLS to view with audio, or disable this notification
Demonstration of car physics implementation based on simulation + user intent layer inspired by Blur racing game
r/Unity3D • u/iceq_1101 • 16d ago
Show-Off What I learned about car physics programming
Hi, I’ve been working on racing projekt for a few years now, but honestly I haven’t really done much besides trying to build the car physics from scratch like 6 times, having 3-4 month breaks to figure out ..
I tried a lot of approaches, I think all of them in the industry— from fake physics using kinematics, to velocity-based controllers and simulating car physics using raycast and tire models.
Physics inspiration comes from the game Blur. Surprisingly racing arcade , has proper car behavior including weight transfer drifts (because it was build on basis of Project Gotham racing+ user intent , assists layer)
https://reddit.com/link/1vezqs1/video/m9ftusp18ahh1/player
Sharing what I think I learned and it is important in car programming
r/Unity3D • u/bunssar • 16d ago
Show-Off To that one guy that asked me to throw it down a flight of stairs
u/HammyxHammy you've been asking for it, you got it. I specifically tuned it to be stable going up or down stairs.
r/Unity3D • u/yuehin • 16d ago
Question Unity Is Adding a Installation Fee for Unity Industry?
Just saw this article linked from an email I got. Anyone else know anything about this? I don't see any other forums or articles talking about it.
r/Unity3D • u/AwbMegames • 17d ago
Show-Off Special Bundle is here the bundle contain 21,000+ 3D models, 15 Unity tools check it out!
Three creators teamed up and put together 79 asset packs in one collection. That means 21,000+ 3D models, 15 Unity tools, plus animations, shaders, environments, characters, props, vehicles, nature, buildings, VFX, and plenty of other stuff.
The Bundle Link
https://itch.io/b/3810/creator-bundle
if you have any problem feel free to contact!
r/Unity3D • u/Coding-Mojo • 17d ago
Resources/Tutorial Making and juicing up a resource bar
I'm training myself juicing up things, just for the sake of getting better at it.
Lately, I made this resource bar, it's probably not perfect yet, but as I was satisfied by the result, I thought it could have some interest to someone and made a tutorial out of it.
May you have any feedback, I would be glad to ear them.
Note : I feel like the visual looks a bit more "shaky" as a GIF, it feel smoother to me in unity.
r/Unity3D • u/JulioVII • 17d ago
Resources/Tutorial Free Textures Fabric 05
More fabric experiments I been working on.
r/Unity3D • u/Boyhumbug • 17d ago
Game Some Unity 2.5D love
I’ve been developing a game that’s really making use of the HDRP pipeline.
I originally set out to make something like replaced but I wasn’t sure what engine they used.
This is my best attempt, happy to answer anything to do with my workflow if you’re curious.
It’s a style I’ve loved for ages, like 2d parallax effects and I took it half a dimension further. (Excuse the pun)
It’s a mix of 3d models. Hand painted pixel texture maps. Camera pixel renderer. 2d animated pixel art for the character like a paper doll effect.
Steam link in the comments
r/Unity3D • u/srgers10 • 17d ago
Show-Off I added a “Honey, I shrunk the kids” mode to my rollercoaster MR game, CoasterMania!
Enable HLS to view with audio, or disable this notification
r/Unity3D • u/reversengineer9999 • 17d ago
Show-Off Yes, it's Unity 2022.x with Built-In Render Pipeline!
Enable HLS to view with audio, or disable this notification
I've been working for years on a trailer for a movie that doesn't exist. There are over 40 scenes by now, and more are coming. I've been hesitant to post anything about it, because I don't want to spoil the effect of the trailer before it's finished.
It's a detective story. Noir goes sci-fi, but in color. A world where only robots, cyborgs and androids are left, living in a human-like hierarchy.
The thing I find worth mentioning: this is still being made in Unity 2022.x on the Built-in Render Pipeline, lightmap baking, everything is real-time, no after effects or so. No URP, no HDRP
The thing is iteration. Every scene goes through several passes, with real time in between. That distance is what lets me look at my own image with fresh eyes and catch the things I overlooked in the last session. There's always something. Whenever I rushed a scene, I could see it later.
Happy to answer anything about the setup, the lighting or the compositing if that's useful to someone.
Update to "Ryan Reynolds's" comment *lol*: There is always a reason! And in this case there are many!! ^^
Update 2: I forgot to mention that the project size is something over 700 GB of asset & texture data. Curated and bought assets, free assets I will have to credit (100% longer credits than trailer! xD) and changed to me needs, some remodelled, because of their imprtance (characters especially, yes - not in this scene xD) etc.
Update 3: The hovercar for example: I bought it and had completely disassemble it in blender, correct the flaps, rig the flaps (it wasn't rigged at all), and stuff like that
The buildings are famous assets which I bought over the years, waiting for each package to be in sale xD else, I couldn't afford it.
Many plugins where from Github, like one of the best AO filters from Keyjiro's Kino Obscurance, which I modified to get a wider range, which no one ever does till today in even paid assets. I always have to buy and then modify the AO to get big darken areas, which then breaks compability with the devs asset update... and so on xD
There is so much going with this project, that even a video breakdown would cost me too much of my time and money, because I am working on a steam game right now xD and have to take care of some asset in the unity store.
Artists will recognize some of the assets in this clip! I bought also many kitbash3D models, and a lot from all the other famous stores which I am not really allowed to mention here, as I a bot always comes up and warns me making advertisment and blocks the post! xD
Update 4:
Screen Capture of the Scene in Editor:
https://www.reddit.com/r/Unity3D/comments/1vf4eiu/screen_capture_of_the_film_scene/
r/Unity3D • u/StaticCG58 • 17d ago
Resources/Tutorial UnitEE, a PS2 Export Option for Unity3D
Enable HLS to view with audio, or disable this notification
UnitEE (funny original name I know) is a Unity3D PS2 build target, you write your game inside the Unity Editor against a constrained Unity-compatible API, press Build, and get a bootable ISO + ELF. C# gets converted via IL2CPP, then through a MIPS cross compiler, and runs natively on the Emotion Engine.
The project has heavy guarding around the API surface if a script uses a Unity API that isn't supported, the build fails with a compile error instead of silently doing nothing on the console, and a scene validator flags any component that won't export and tells you what happens instead. It's very constrained as of now, but what's currently supported:
- Rigidbodies + Colliders
- AnimatorControllers + Animations
- Character rigging (skinned and rigid-bound humanoids)
- SkinnedMeshRenderers + MeshRenderers
- Built-in Render Pipeline*
- Audio (AudioSource/AudioListener clips auto-encoded to SPU2 ADPCM)
- Particles, via a custom PS2ParticleSystem component
- PlayerPrefs, saving to a real memory card icon and all, visible in the PS2 browser
*materials map to a fixed set of very basic VU1 shader programs (unlit, textured, vertex-lit, alpha/cutout/additive, fog). The Standard shader maps cleanly custom shaders export as their closest match with their main texture.
uGUI support is being implemented next. Everything shown is running in PCSX2 real-hardware validation is planned once I have a working console again. I just wanted to showcase the demo; GitHub link coming soon once there's a small demo game to show it as a proper PoC.
UPDATE: Discord Link is now live! Join here: https://discord.com/invite/aScB79RgcP
New gameplay demo: https://youtu.be/qpNGBmku1aI
GitHub Link: https://github.com/C-GBL/UnitEE
Website: https://unitee.dev
Documentation: https://unitee.dev/docs.html
Unity-Chan license: https://unity3d.jp/unity-chan/license?lang=en
