I am making a disc-like object with a rounded outer rim. I need it to roll very smoothly. I can achieve that with a sphere collider, but that has a lot of problems. Even if I did the workarounds necessary to get the disc to move normally with a sphere collider, it would take more calculations and tick updates than I’d like. It would also leave the collider sticking out on the sides, which is not going to work for my project. Capsules will also not work, since I’m dealing with a disc and not a tube. And even in the case of a tube, the ends of the collider would still stick out
I have attempted to use Auto Convex Collision, but even with the maximum settings, it doesn’t provide a smooth enough surface. I could achieve it with a sphere and 2 boxes that overlapped it on either side, if booleans were allowed for collision meshes. I imagine that if that were allowed, the engine would do something like this, and probably wouldn’t need to work much harder:
“Oh, look, collision mesh A hit something! Oh boy! But is the point of contact within collision mesh B? It is? Well, I guess we won’t consider it a collision for physics purposes, then. Darn.”
That seems like an obvious move, and I’m really hoping that I’ve just missed something obvious. Can someone please tell me I’m missing something important?
I’ve looked around quite a bit, but it also doesn’t seem like curves of any kind other than spheres and capsules are supported in any way. Is this actually right? It seems like it should be pretty simple to squish a sphere collider until it was thin enough for what I need, but scaling a sphere collision mesh on any axis just scales the whole thing, apparently. I understand that there would need to be an additional calculation for the shape and orientation of the resulting spheroid, but it doesn’t seem like it would be too cumbersome to use, particularly if it’s only used on important objects.
Has anyone done something like this? Does anyone know how to get this sort of result? Is there some dark ritual magic I need to perform to make a round-but-not-spherical object roll? Any help is appreciated.
On the mesh editor Details tab > Collision, there’s a property “Complex Collision Mesh” which might just be what you need. Try modelling a cylinder mesh and setting that property to it?
That will not work unfortunately, as complex collision is for static objects only, and I need this object to move.
Edit: Moveable objects can have a complex collision mesh, but it will only use a simple mesh for physics. Attempting to use the Complex mesh as simple option will just throw errors for a moveable object.
The two main uses where “cylinders” are needed rather than just well tesselated convex hulls, or box stacks, is:
Barrels. Best work-around is to use a capsule, and stick a box on the inside that doesn’t go outside the barrel walls. The box lets it stand on flat ends; the capsule lets it roll when knocked over.
Wheels. This is for car physics. Generally, using boxes for side collisions, and using ray casts for wheel/suspension/contact/friction, will let you get far enough.
I wonder what the Chaos vehicle use for its wheels?
There are a couple of problems I can’t easily fix with those solutions. First, the edge of the disc is rounded, and I need it to be rounded. A cylinder could work, but would give me some odd lifting from the ground when the disc tilts, and it would need to be very smooth. This is one of the main components of the scene, and will be used almost constantly. I need it to roll smoothly, like a disc would. Any oddities in its motion, like rocking back and forth between two edges when it comes to a stop, or like lifting slightly and falling back down will be immediately noticeable and jarring. Sphere and Capsule collisions are the only things I’ve found so far that roll smoothly. Unfortunately, since the disc is thinner than its circumference, a capsule is no different than a sphere for my purposes. If it was a long shape with a small diameter, I could use a sphere or capsule and the end blocks. Even if it was tapered, I could use multiple spheres. But those options don’t work for this.
No discs exist physically – they are all (thin) cylinders.
If you want 100% “smooth, on rails” movement, then perhaps an animation-based approach, or a spline-following approach, would be better than physical simulation?
Another option would presumably be to crack open the C++ implementation of Chaos and build the Disk primitive. It looks like such a thing could be plugged in, but that’s obviously a bunch of extra work …
I understand about the disc/cylinder thing. You’re right, and if I had a smooth enough cylinder, I could almost use that and be fine. The issue is that the shape I need is actually rounded on the edge, making it more like a narrow spheroid with the sides sheared off. You may be right about having to use animations or some other alternative. It would be really nice to be able to use the physics for motion, since there’s so much it does natively, but I should be able to get satisfactory results without it. I did look at editing an existing primitive, but you’re right that it would be a lot of extra work. Also I’m trying to avoid including C++ in general, since using visual studio professionally is expensive and unreal won’t use alternative compilers (because reasons, I guess). Maybe I’ll look into making such a primitive in the future…
When I say “cylinder” I mean a collision shape that is actually a parametric cylinder, such as used for wheel colliders.
There is such a shape defined in Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Cylinder.h
(There is also a Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/TaperedCylinder.h btw.)
Now, these don’t have simple actor components that you can add in the Blueprint editor, but the Chaos Wheeled Vehicle does seem to use them, so presumably they work when you use them in C++. I have not tried it, but if I needed a smooth rolling cylinder, I’d check out what the WheeledVehicle does with these, and go from there.
I was surprised to find that is Chaos there still is no cylinder collison. Everyone who works with the engine runs into this same issue with no cylinder collision. It is interesting that the Unigine engine has a cylinder collision.
Excellent information Jwatte! How would you be able to get the cylinder to work in Chaos? I use BP and not forsure how you would go about making that work. I had created a thread to get some help on making a convex cylinder work but have not gotten any help yet. If you can make a cylinder collision somehow with C++ I would love to know how, maybe a plug-in or someway to expose to BP. Collison Geometry for a Physics Based Motorcycle?
I would just like to put my hand up as someone who is in exactly the same boat. It seems physics driven bicycles/motorcycles are inherently going to be a problem with the limited choice of collision primitives.
And I agree- a boolean type system, where you could chop out the sides of a sphere with a couple boxes on each side, would do the trick!
My only advice here if you are not C++ proficient (as I’m not), is to maybe employ the help of an AI assistant, such as Claude AI, which I used recently to help me to develop a C++ plugin, which worked very well. I will probably go down this path soon to see what I can do, because the custom or generated mesh options don’t seem to be working out too well so far.
Bycycles are just cars with 4 wheels that have 4 invisible wheels.
And no, using Claude or ChatGPT is a horrible idea if you don’t know enough to verify what it gives you back. Actually its a horrible idea even when you do know enough…
Really. What’s wrong with you just learning what you need to learn to achieve what you want to achieve?
Is it an “I’m against learning” thing or what?
Because AI isn’t really going to save you time.
But you can exploit the AI to actually learn instead…
Additionally, do keep on mind that Chaos Physics can barely do cars.
Attempting to make a completely useless accademical realistic bycycle would definitely be near impossible.
If not just for the fact that the engine physics don’t really understand the concept of gyroscoping…
You would basically need to write a classical mechanics setup to get it to work.
And the OP issue was a decent one, in academic terms.
A circle has infinite precisions whereas any defined collision does not.
Thus, making a sphere or a sphiel would allow for perfect “rolling” while using custom collisions would not save for very complex and expensive versions.
When all you need is a radius definition for the math to work, and you don’t have that option - yes, it does seem like the engine is lacking. Which it 100% was and still is, and likely will always be.
You should probably stick to box collision.
A box is also a circle. With corners.
You just fake the object rotation without having any physics to it, like all the cars do…
Because of the corners you will likely need to adapt smaller than radius objects to provoke fake collisions - so you can use collision channels and a sphere the exact size of R to define/check that collision and apply impulse to the object or similar
My thinking was if something isn’t present in the engine, then we may have to think about creating it.
I recently required a blueprint callable C++ plugin, which could read 3d point data from a file and build splines from them. I couldn’t do something like that with blueprints, so C++ was the only way. I learned a lot, firstly about creating a plugin for Unreal (which I’d never done before) but the plugin went through numerous iterations and with the AI help, was able to build something which was very useful and very specific to my own project.
What I’m trying to say is I’ll take help where I can get it.
With more thought and reading last night, I decided that trying to add cylindrical collision to the engine was probably hubris, and that using a custom convex mesh of a cylinder was really the best way to go. I’ve only tested on flat, non-complex ground surfaces for now, but a cylinder authored in Maya with about 100 subdivisions is working pretty well in terms of rolling ability and performance. My previous custom collision meshes had less subdivisions and were causing issues.
In my own project, I’m trying to rely on ‘natural’ physics where I can apply them- if something ultimately needs to be canned, then that’s ok- but it’s not my philosophy here. The bike isn’t a car with invisible wheels… it can fall over and requires the player to shift his/her weight, like a real bike. Using physics constraints at various points provides lots of great stuff- like realistic suspension, acceleration and braking. Tweaking physics surfaces with various levels of friction is a very intuitive way to handle riding on different surface types and the result is dynamic, and looks and feels natural- the way the back tire skips and jumps a bit under braking/sliding as it loses and regains traction.
While the physics route might be a headache, in the end it’s the same approach you are basically advocating - ‘Why not stick to…’. Whether using physics or a more controlled ‘canned’ approach, ‘basically impossible’ is always going to be the final answer, so why not have some fun with whatever route you’re taking to get there?
Another quick thought last night as I was trying to sleep…
But wouldn’t a torus work as a pretty decent primitive collision shape? It is basically a capsule but instead of defining a volume based on line length along another line, it would be based on line length from a circle.
It would be more expensive than a sphere, but would it be much more expensive than a capsule? Anyway it would make a perfect collider for thinner wheels, since it’s a perfect bike tube shape to begin with.
A sphere uses simple calcs. A box though it seems like more uses less (because easier math without pi amd in parallel on any engine). A sphiel is 3rd because of Pie plus dimensions (as opposed to sphere).
A taurus would be 2 Pi and … well im not sure the math to figure out the collision is easy at all. Its not super hard, but its 2x more than sphiel already.
I could see it being useful, but if you split the math and do it of a box collision you get the same end result plus, you have to anyway.
If you were to write your own physics engine you would firstly set up to check that the box containing the tourus was hit.
Then you would check if the circle containing the taurus was hit.
Then you would check if the circle of the taurus was hit at the location where the circle was hit.
Thats 3 calcs. When the idea behins the primitives is that you just do the math and get a straight up result.
Cant the math give one result just for the taurus? Maybe you could write a formula. But because of PI i bet it would cost (tame more time) than the exclusion checking above.
Hence why its not a common shape in any engine i know of…
Re the rest.
Mind you that even Motocross Madness used the equivalent of a car to power motorcycles. Its common place and produces really good results when done right.
A torus is more expensive than a sphere, true, but if you have two of them in your entire scene, you’re not going to see a difference. Even if you have ten bikes, each with two torii, the extra computations needed to collide a torus compared to a sphere are unlikely to ever show up on a profile.
The main challenge would ge that Chaos by default doesn’t support toroidal colliders, so you’d have to write and plug that into the engine yourself…
But, colliders aren’t seen by the user. You can cheat! You can use a thin box or convex hull that’s slightly smaller diameter than the wheel itself, and not perfectly round, but then also a smaller sphere at the bottom to get the “rounded” collision.
Remeber the whole point above was that the OP/or just a user wanted the disk to move smoothly with physics.
@jwatte
I think its overkill, which is why I have never seen it on any non-custom engine.
But the fact there are a few custom engine that have it should mean there are some user cases for it.
The point of cost however is that you can branch the checks I listed and get a possibly faster result (since its not involving pi on at least one front).
If you want to visually represent that solution as a Tourus you can - but creating visual colliders in engine is more problematic/expensivd than just doing the math. By a lot…
Even with simple drawdebugsphere which we all surely used billions of times…
Physx wheeles used simple discs - but it was only visible by issuing console commands to display the physx colliders.
PXVIS COLLISION
Actually discs are pretty expensive too (if they’re modeled as narrow cylinders.)
I remember using capsules with intersecting boxes that had the same diameter but made the top/bottom flat, for a large barrel stack in the past, and that was cheaper.
Aaanyway, how about just making it from two spheres, put a heavy weight below ground to balance it, and call it good?
There’s 1000 and one ways to do this even within chaos physics. The thing is as 2 cylinders or as 2 spheres is pretty much never going to be stable.
Even with 3 (a trike) it’s going to fall a lot, which is why the industry standard is to make a car that functions as a motorcycle - with which you custom fake all interactions.
I figure the guy just wants to learn for the purely academic aspect of things.
Re the cost of a cylinder, I think it’s simplified to just check the general area of a box of the same diameter first, then do a secondary check if a hit is there for the actual Pi variation.
That’s how someone sane would code it… but then again the new system is called Chaos, so…