I’ve been trying to make a car chassis. I started working on the transmission, and I thought I would calculate the engine RPM from the wheel RPM and gear ratio. It didn’t work out well. When I tested the car the RPM reacted weirdly. I decided to see if RotVelocity.Magnitude is returning alright values, so I linked it to one of my car’s tires and made it print() what was returned quite frequently. The results can be seen in this clip:
(I’m having trouble uploading it for a few days, I’ll try to edit the post with an even shorter version of it at a lower resolution soon. So for now I’ve explained what happened below.)
Edit: Here’s the video:
Make sure to keep a close eye on the numbers in the output. While I drove the car, mostly a single value near zero was given whether I was at idle or at full speed. When I dropped it from the sky, it returned fluctuating values. I’m a bit confused, sorry for the bad explanation. I’ll try answering all questions asked in the replies. Thanks in advance!
Edit (5/10/19): I’ve tried a load of stuff, ranging from wheel.RotVelocity:Dot(wheel.CFrame:VectorToWorldSpace(Vector3.new(-1, 0, 0)))
to primary.CFrame:vectorToObjectSpace(wheel.RotVelocity - primary.RotVelocity)
, but I haven’t been able to calculate wheel RPM properly. Anyone help me with this?
Edit 2 (5/10/19): Here’s a really basic place file with a basic version of the chassis, engine, drive-shaft and wheel RPM are printed in the output every second. RotVelocity error repro.rbxl (616.2 KB)
Well first of all .Magnitude returns the “distance” of a vector. It’s not anything specific to where the Vector came from (e.g. RotVelocity). Secondly, if you are using special constraints getting RotVelocity can yield results you’d think to be weird due to how these constraints work.
There is not enough information here without the video and there still may be not enough info. I can’t tell how the wheels turn, the problem you are having is very unclear (other than just “weird results” I know nothing about your issue), I can’t see any code in case there are bugs, etc.
If you try getting the RotVelocity and then setting it again on Heartbeat do you see any weird or unexpected physics occurring? Are you getting RotVelocity in a loop out of sync with Heartbeat? (Syncing with Heartbeat is probably a very good idea when doing physics related stuff)
When your car falls does it turn or spin as it does this or is it a perfectly linear fall? Since your wheels don’t show a good RotVelocity when driving but fluctuate when falling this seems to be a big arrow pointing towards the RotVelocity not being set to when your wheels turn.
Try uploading your video to Youtube and see if you are able to upload it.
Alright thanks, I’ll try uploading it to YouTube. I used RotVelocity.Magnitude as Widgeon told me to do so. The fall is linear, and the wheels are spun using HingeConstraints with the ActuatorType set to Motor. I don’t think there should be any script errors as I’m just getting the RotVelocity.Magnitude every 0.25 seconds and printing it, and I also tried printing it every heartbeat. No unexpected physics are occurring. A lot of things should be cleared up once I upload the video, sorry for the inconvenience. I’m gonna go upload the video now, sorry if it takes some time as I have slow upload speeds.
Thank you for this information in the meantime!
I can maybe take a quick guess and maybe say HingeConstraints aren’t actually setting RotVelocity for some strange reason and perform their own physics calculations?
I’ll do some tests when I get home (probably in a few hours) and see if this is the case
Hmm that’s possible. Thanks for your time! Sorry if this video takes about half an hour, that’s how slow my upload speeds are. Download speeds are alright.
I’m not an expert at vehicles, but perhaps try rotating your constraints to face the correct direction.
Otherwise, you can also use Coordinate Frame to vector your bearings to the correct direction.
part.RotVelocity:Dot(axis) gives the rotation along that axis, if that helps?
I’d do something like (wheel.RotVelocity - hub.RotVelocity):Dot(hub.CFrame:VectorToWorldSpace(Vector3.new(-1, 0, 0))) or something… Adjust the Vector3 as needed, I haven’t really read the thread but I hope this helps…
I’m trying it out right now, I’ll let you know of the results. Thanks!
I had a question by the way. About the :Dot()'s Vector3 value, if the wheel’s RotVelocity changes on the Z axis when it spins, should I use Vector3.new(0, 0, -1)?
As a note to anyone who reads this, me and Terrodactyl played around with both the equations he provided on Discord, yet we did not get desired values.