How can I make a physics object rotate only by applying forces or directly through transform and make it non-rotateble by colliding with other objects at the same time? Colliding with other objects should block it linearly and don’t make it rotating. At the same time - very important.
Sounds like you’re wanting Constraints.
They’re kind of hidden on the physics.
You can selectively lock any axis for motion or angular changes against all things you don’t apply directly.
If you tick the box for X rotation, it can still be spun around the other 2 axis by impacts, but the X rotation will remain exactly where it is.
But you can change its X rotation with set world rotation or set relative rotation.
I’ve tried to find a way to disable impulse on collision, but I don’t think it’s possible without altering the underlying engine code.
What if you try doing it with two components: the outer invisible component with its rotation locked, and the inner visible component that rotates? You can make both of them simulate physics, but use a Physics Constraint on the inner component to bind it to the outer component.
This way you’ll have the outer component that handles collisions but does not rotate, and the inner component that rotates but never collides with anything that may affect its rotation.
After rereading your question… this won’t allow you to rotate it by applying impulses.
But you can simulate that rather easily…
Estimate the total time of rotation to make timelines, calculate the estimated total rotation change, then use the timeline to drive a lerp between initial rotation and that final rotation.
It’s extra work, but allows for what you’re wanting to do short of going into native C++ and doing vector math.
“I’ve tried to find a way to disable impulse on collision, but I don’t think it’s possible without altering the underlying engine code.”
Yes, I was hoping to avoid that too. Anyway, thanks for your reply. I didn’t expect anyone to answer at all. But the constraints are unfortunately a little not what I need.
But you seem to understand the issue. I am doing linetrace a car, an SUV. The collision consists of two primitives of spheres, and, as it should be, the center of mass is shifted downward to increase stability, but during jumps and hits, I would like to avoid any rotation at all, and the suspension force works constantly and the car, for example, when driving into a wall does not must rotate, and must maintain direction.
In general, all physics is quite simple, no gearbox, no complex friction model, very arcade physics. Is it possible to simulate the suspension forces using only math, without resorting to built-in physics?