Get wheel odometry?

I want to trigger an event every time a wheel passed a certain rotation value. How can I accomplish this? Can I get the amount of rotations for a wheel at a certain timepoint?

Are your wheels using physics? (They probably are.) If so, you should be able to use Get Physics Angular Velocity in Degrees to find out how fast your wheel is rotating each frame. Here’s how I would try setting it up:

  1. Create a float variable in your Blueprint that will keep track of wheel rotations (call it something like “WheelRotationDegrees”)
  2. Find out whichever channel (X, Y, or Z) represents the rotation axis of your wheel
  3. Each frame, add the value of this channel to your “WheelRotationDegrees” variable
  4. Each frame, if the updated value of your “WheelRotationDegrees” variable is greater than 360, subtract 360 and call up whatever event functions you want

Additional thoughts:

  • If you want your event functions to be able to be called up more than once per frame if the wheel is rotating extremely quickly, you’ll want to divide your “WheelRotationDegrees” value by 360 and fire off your event functions that many times; e.g., a value of 823.8 degrees would cause your functions to be called up twice (823.8 / 360 = 2.2883, which floors down to 2)

  • Make sure you use the Absolute (float) on the value of your wheel’s rotation to make sure you fire off events no matter which way (forward or backward) the wheel is rotating

Hopefully that makes sense! If you think you’ll need example screenshots of how it would look in Blueprint, let me know and I’ll upload something as soon as I can.

Thanks very much for your detailed answer! I did unterstand your thoughts with one remaining point. How can I fire an event twice a frame, if the wheel rotates for. e.g. 721° in one frame?
I’m aksing that because I’m sending chars to a comport out of the game to an external device to use the odometry