Download

Vehicle Tire Skid

Hi!

How can I detect whether one or more tires of a Wheeled Vehicle is skidding both at launch or hard brake? If it is easier I can implement as C++.

Thanks.

A simple way would be to take the velocity vector of the wheel, and check for longitudinal skid by comparing speed along that axis with the tangential speed of the rotating wheel, which is equal to the radius * rotational velocity (in rad/s).
Of course, you can also check for sideslip without having to consider the rotation of the wheel.
And you should have a threshold to account for float point precision and generally avoiding your tire to skid too easily.

Thanks for the answer. How can I get the rotational velocity of the wheel?

hi, also interesting thing for me, maybe some one can give example?

From what I found in the docs (I’m quite new to UE4 myself), it seems your object has to be a physics object - I guess that’s the case when you simulate physics. There is a Get Physics Angular Velocity node, which returns a vector in deg/s.
I didn’t find a similar node for general objects, and am not sure whether it works on animated objects (not physically simulated), but that could be done manually.
In your case, you could use that node on each wheel, convert to rad/s, and then to linear velocity (you will have to check for world vs local axes, as I don’t know what the node actually returns).

I’ll see if I can get a simple example running and keep you updated.

Alright, I got a simple example working, you can get the project files in the attached file to see how things are working.
As I said, you get the wheel’s linear and angular velocities, and compare the wheel’s spin (Z axis in my example), converted to linear velocity, to the wheel’s linear velocity along X and Y (root of the squared sum).
Throw in a few absolute values and a threshold value, and you’re good to go. The main trick here is to get the velocities in the wheel’s local space; I did this using the Unrotate node.
I also added sideways slip detection by comparing velocity along the Z axis with the threshold, but you may want to multiply that by an arbitrary factor if you want to account for… erm I forgot the technical terms, but a car’s wheels can have non-zero transversal speed due to the tire/tyre’s deformation, so it will only slide when the transversal speed is higher (or when it is the only component of the wheel’s velocity).

In the example I included, you can press G and H to add torque to the wheel, and the state of the IsSkidding function is displayed every tick.

Project URL (since I can’t upload a zip this size): Dropbox - Error
I might add screenshots for posterity (if other people encounter this issue), but the gamejam is about to begin, and I want to try making something ^^; so maybe later.

Hi,

Thank you for the example, but your example is for a simple cylindrical static mesh. Vehicle dynamics is very different in UE4 and it is all dependent on NVidia PhysX. After some investigation, I found that PxWheelQueryResult has what I want. Giving some tolerance to LongSlip and LatSlip will do the job. You can view detailed stats in UE4 by the console command “showdebug vehicle”.

You can query PxWheelQueryResult from PhysXVehicleManager class but it is private. However, UWheeledVehicleMovementComponent has method called “CheckSlipThreshold” which is all wheels based query instead of wheel by wheel query. Anyway it works for me.

My C++ solution is:

Header file:



	DECLARE_DYNAMIC_MULTICAST_DELEGATE(FStartSkidding);
	DECLARE_DYNAMIC_MULTICAST_DELEGATE(FStopSkidding);

	UPROPERTY(Transient)
	bool IsSkidding;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skidding")
	float LongitudinalSlipThreshold;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Skidding")
	float LateralSlipThreshold;

	UPROPERTY(BlueprintAssignable, Category = "Events")
	FStartSkidding StartSkidding;

	UPROPERTY(BlueprintAssignable, Category = "Events")
	FStartSkidding StopSkidding;

	virtual void Tick(float DeltaSeconds) override;


CPP file:



void AMyWheeledVehicle::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);

	bool SlipThresholdExceeded = GetVehicleMovement()->CheckSlipThreshold(LongitudinalSlipThreshold, LateralSlipThreshold);
	if (SlipThresholdExceeded && !IsSkidding)
	{
		StartSkidding.Broadcast();
		IsSkidding = true;
	}
	else if (!SlipThresholdExceeded && IsSkidding)
	{
		StopSkidding.Broadcast();
		IsSkidding = false;
	}
}


Thanks anyway for the help.

This will come in handy, thanks.

Hi KashiKyrios,
I’ve been trying to tackle this problem in the same way, but with limited results (the tire rotation I’m getting is way too noisy.)
It looks like your Dropbox link is outdated. I don’t suppose there’s any chance you could re-post it, or some Blueprint screenshots maybe? :slight_smile:

Cheers.

I had deleted the project some time ago, but I made a new one so I could post it here again.

You can use the F and G keys to add torque to the wheel, which will display “SKID” when it skids past an arbitrary threshold.

This simple test only checks velocity against static objects, for moving objects, you would have to subtract the velocity of that object at the contact point.
Also, by projecting the relative speed between the wheel and the ground, you can have separate thresholds for longitudinal and side-slip.

The project is attached to this post, feel free to check it out.

Thank you very much!