#⚛️┃physics
1 messages · Page 85 of 1
and my character started moving way slower
of course, I may increase forwardSpeed and other speeding constants, this will fix issue, I think. But.... I am curious - why movement was faster when FPS was rocketing to 400
@open escarp You gotta move those grabber arms with force
Rigidbody2D.AddTorque?
@open escarp That would work if you want to use that
or maybe some joint motors
I'd prefer torque
Hmm, maybe joint motors would better though
Thanks, I will try both
If you do torque, one arm might close fast while the other arm is pushing against the balls
It would be better to control the arm angles in a stable way
Thanks
np
you can gather input in Update but you should mess with rigidbodies only in FixedUpdate
do I rename Update to FixedUpdate?
All of this Update code should be in FixedUpdate
Given two rotations, a and b, how do I determine the torque needed to move the Rigidbody from a to b, ignoring its mass (Forcemode.VelocityChange)
Torque gives you a velocity
not a difference in rotation
similar to how force gives you a change in velocity, not a distance
technically any amount of torque will get you to b (as long as it's in the right direction)
the question is how long will it take?
And at what angular velocity will you still be spinning when you get there?
I wish to move a dynamic rigidbody from rotation a to b over one frame, using AddTorque and subtracting its angularVelocity
if you want to just do it over one frame, don't bother with torque. Use MoveRotation
I need the body to report that it has an angular velocity, it's a spinning platform the character controller will ride whose properties are being analyzed
I think this would do it?
Quaternion start;
Quaternion end;
Quaternion diff = end * Quaternion.Inverse(start);
// required velocity to do that diff in one physics frame:
Vector3 angularVel = diff / Time.fixedDeltaTime;
rb.angularVelocity = angularVel;```
We can also make that done with torque but it'd require a few more calculations with the current angularVelocity and the moment of inertia of the body
Another requirement I guess I should have mentioned is that I have to use the freeze rotation rigidbody constraints as I want to only move this dynamic body myself, with no consideration to any other rigidbodies
@timid dove
So I must use AddTorque
I usually just do something like this:
rb.AddTorque(torque - rb.angularVelocity, ForceMode.VelocityChange);
It appears I cannot set angularVelocity on a rigidbody with frozen rotation constraints, while AddTorque still works
(I recognize this is rather niche)
maybe I can get a signed angle delta on all 3 axes
The only effect of AddTorque is to modify the angularVelocity
it won't let you get around rotation constraints being enabled
That is not true
unless Unity is bugged, AddTorque does let you circumvent constraints
Possibly only ForceMode.VelocityChange has this effect
that would be even more surprising than the previous revelation
give it a try 😐
(also, can we keep this on the down low? I don't want Unity to "fix" this... lol)
later I will
@timid dove the following appears to have gotten me what I wanted:
Quaternion fromRotation = //...
Quaternion toRotation = //...
Quaternion deltaRotation = Quaternion.Inverse(fromRotation) * toRotation;
Vector3 deltaAngles = deltaRotation.eulerAngles;
if (deltaAngles.x > 180f) deltaAngles.x -= 360f;
if (deltaAngles.y > 180f) deltaAngles.y -= 360f;
if (deltaAngles.z > 180f) deltaAngles.z -= 360f;
rb.AddTorque(deltaAngles - rb.angularVelocity, ForceMode.VelocityChange);
Hey everyone! ive been trying to make an online movement shooter but i keep running into this issue, i tried everything i could but could not figure out the issue 😦
Would really appreciate if anyone could help
using a Character Controller
Not using any particles
You'd have to share your code but you're doing one or more calculations that are resulting in NaN and trying to use that somewhere that is upsetting things
I found a workaround, basically limited everything that could lead to infinity or NaN