playMaker

Author Topic: [SOLVED] How to get rotation in degrees/second? (for Car Wheel)  (Read 2438 times)

bizilux

  • Full Member
  • ***
  • Posts: 171
hey all.

so im making 2d driving game. anyways long story short, im using hinge joint, and setting motor speed for driving forward and backward. right now it is at 1000 for accelerating, so that means, 1000 degrees of rotation per second.
1 full rotation is 360 degrees, so it means that in one second, wheel does almost 3 full rotations.

but then when player lets go of throttle, i return to idle state, where i just disable "use motor" on hinge joint.

so now comes the tricky part. i need to know at which degrees per second does the wheel turn at.  because when player hits throttle again or reverse, wheel rotation needs to start at that value, or else it looks non-natural.

i was fiddling with it for 2 hours now, and couldnt really produce any satisfactory results...

this is what i have now... im using get rotation, and float compare, and then resetting it each second... but i wonder if there is more elegant way of doing this...

my way is not precise way... it doesnt show the same degrees/second as it should be... its always off by 1 rotation, either 1 more, or one less. i need like a really precise method, that will show exact degrees/second
the faster the wheel turns, the more not accurate my method is... so i think i need new approach.
« Last Edit: July 05, 2014, 10:58:01 AM by bizilux »

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: How to get rotation in degrees/second? (for Car Wheel)
« Reply #1 on: July 04, 2014, 01:35:40 PM »
this is what i have right now :)

just need a way to get wheel rotation

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: How to get rotation in degrees/second? (for Car Wheel)
« Reply #2 on: July 05, 2014, 10:57:40 AM »
yay!

solved it... its Angular Velocity under 2D rigidbody properties...

the only problem then is, that when car is going forward it displays negative velocity and when going backwards it displays positive velocity,  its because wheel is rotating in that way... so what i do is i multiply that value by -1, and that changes float signs

oh and btw: i deleted that whole FSM that i had before... where it counted rotations per second and all that... now i just have this simple 2 actions, and it works as it should... car handling has never been any smoother :)

i will probably make Playmaker 2D Driving Kit and put it on asset store
« Last Edit: July 05, 2014, 10:59:40 AM by bizilux »