# Change Vehicle Wheel Tire Type at runtime

**URL:** <https://forums.unrealengine.com/t/change-vehicle-wheel-tire-type-at-runtime/336932>\
**Category:** World Creation\
**Tags:** wheels, friction, vehicle, wheeled-vehicle, unreal-engine, question\
**Created:** [October 30, 2015, 1:06am UTC](https://forums.unrealengine.com/t/change-vehicle-wheel-tire-type-at-runtime/336932 "2015-10-30T01:06:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![piinecone](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@piinecone](https://forums.unrealengine.com/u/piinecone)\
**Post date:** [October 30, 2015, 1:06am UTC](https://forums.unrealengine.com/t/change-vehicle-wheel-tire-type-at-runtime/336932/1 "2015-10-30T01:06:16Z")

</div>

How do I correctly change the UVehicleWheel **TireType** at runtime? I can set it with something like:

`GetVehicleMovement()->Wheels[i]->TireType = MediumFrictionTiretype;`

but the assignment doesn’t seem to have any effect. I tried reinitializing what I safely could without any luck.

The issue with setting something like the `FrictionScale` for the current `TireType` is that it affects all instances of a given vehicle class, so if one vehicle’s wheel friction is modified, they all feel it. Since they appear to be shared at the `PhysXVehicleManager` level, I thought a good workaround would be different `TireType`s, and I’m here asking in case separating these at the engine level is a fool’s errand.

@oricohen If you’ve got a moment please let me know if you have any ideas. Thanks!

---

<div class="post-metadata">

**Author:** ![piinecone](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@piinecone](https://forums.unrealengine.com/u/piinecone)\
**Post date:** [October 31, 2015, 10:24pm UTC](https://forums.unrealengine.com/t/change-vehicle-wheel-tire-type-at-runtime/336932/2 "2015-10-31T22:24:34Z")

</div>

An update for anyone finds themselves here:

I took a look at the `PhysXVehicleManager` and I can see that it would be reasonable to include some kind of interface on a `WheeledVehicle` that provides something like a `FrictionMultiplier`, such that when the surface and tire pairs are being assembled for PhysX each particular pair would also be made aware of any vehicle instance-specific friction modifier. However, I didn’t spend a lot of time poking around in there, so I’m not especially confident that that’s a good approach, but I will soon dig further since it will eventually be an issue for my game.

Since my current project is primarily multiplayer, the shared tire type is only an issue for local testing with multiple clients, and that can probably be overcome with a crappy `PlayerOneTireType` and `PlayerTwoTireType` approach. Bots don’t really need to drift so they can just have a `BotTireType`. Not the kind of code I’d like to write but seems like the simplest solution at this stage.

---

<div class="post-metadata">

**Author:** ![Gelani](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gelani](https://forums.unrealengine.com/u/Gelani)\
**Post date:** [June 23, 2016, 4:34pm UTC](https://forums.unrealengine.com/t/change-vehicle-wheel-tire-type-at-runtime/336932/3 "2016-06-23T16:34:46Z")

</div>

VehicleGame.Build.cs

```
		PrivateDependencyModuleNames.AddRange(
			new string[] {
				"Slate",
				"SlateCore",
				"PhysX",
			}
		);

class UVehicleMovementComponentBoosted4w

VehicleMovementComponentBoosted4w.h

	/** Wheel Lat Stiff */
	UFUNCTION(BlueprintCallable, Category = "Wheel")
	void SetWheelLatStiff(int32 WheelIndex, float LatStiffValue, float LatStiffMaxLoad, float LongStiffValue, class UTireType* TireType);

	/** Wheel Friction*/
	UFUNCTION(BlueprintCallable, Category = "Wheel")
	void SetWheelFrictionScale(int32 WheelIndex, class UTireType* TireType);

	
VehicleMovementComponentBoosted4w.cpp
	
#if WITH_PHYSX
#include "PxVehicleWheels.h"
#endif //WITH_PHYSX

void UVehicleMovementComponentBoosted4w::SetWheelLatStiff(int32 WheelIndex, float LatStiffValue, float LatStiffMaxLoad, float LongStiffValue, class UTireType* TireType)
{

	if (WheelIndex >= 0 && LatStiffValue > 0.01 && LatStiffMaxLoad > 0.01 && LongStiffValue > 0.01 && Wheels.Num() > WheelIndex)
	{
		Wheels[WheelIndex]->LatStiffValue = LatStiffValue;
		Wheels[WheelIndex]->LatStiffMaxLoad = LatStiffMaxLoad;
		Wheels[WheelIndex]->LongStiffValue = LongStiffValue;
		Wheels[WheelIndex]->TireType = TireType;

		// init tire data
		// physx::PxVehicleTireData PTireData;
		physx::PxVehicleTireData PTireData;
		PTireData.mType = Wheels[WheelIndex]->TireType ? Wheels[WheelIndex]->TireType->GetTireTypeID() : GEngine->DefaultTireType->GetTireTypeID();
		PTireData.mLatStiffX = Wheels[WheelIndex]->LatStiffMaxLoad;
		PTireData.mLatStiffY = Wheels[WheelIndex]->LatStiffValue;
		PTireData.mLongitudinalStiffnessPerUnitGravity = Wheels[WheelIndex]->LongStiffValue;
		
		PVehicle->mWheelsSimData.setTireData(WheelIndex, PTireData);
	}

	
}

void UVehicleMovementComponentBoosted4w::SetWheelFrictionScale(int32 WheelIndex, class UTireType* TireType)
{
	if (WheelIndex >= 0 && Wheels.Num() > WheelIndex)
	{
		Wheels[WheelIndex]->TireType = TireType;
		// init tire data
		// physx::PxVehicleTireData PTireData;
		physx::PxVehicleTireData PTireData;
		PTireData.mType = Wheels[WheelIndex]->TireType ? Wheels[WheelIndex]->TireType->GetTireTypeID() : GEngine->DefaultTireType->GetTireTypeID();
		PTireData.mLatStiffX = Wheels[WheelIndex]->LatStiffMaxLoad;
		PTireData.mLatStiffY = Wheels[WheelIndex]->LatStiffValue;
		PTireData.mLongitudinalStiffnessPerUnitGravity = Wheels[WheelIndex]->LongStiffValue;

		PVehicle->mWheelsSimData.setTireData(WheelIndex, PTireData);
	}
}
```

---

<div class="post-metadata">

**Author:** ![piinecone](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@piinecone](https://forums.unrealengine.com/u/piinecone)\
**Post date:** [September 27, 2016, 7:02am UTC](https://forums.unrealengine.com/t/change-vehicle-wheel-tire-type-at-runtime/336932/4 "2016-09-27T07:02:36Z")

</div>

This appears to work quite well. Thank you!

---

<div class="post-metadata">

**Author:** ![Pirog](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pirog](https://forums.unrealengine.com/u/Pirog)\
**Post date:** [January 13, 2017, 11:51am UTC](https://forums.unrealengine.com/t/change-vehicle-wheel-tire-type-at-runtime/336932/5 "2017-01-13T11:51:59Z")

</div>

[https://puu.sh/tk7zX/0fb3827155.png](https://puu.sh/tk7zX/0fb3827155.png)

[https://puu.sh/tk7Fm/0c7560b158.png](https://puu.sh/tk7Fm/0c7560b158.png)

It drops many errors about pointers, feels like I’m missing something, any tips?

Found fix:  
#include “Vehicles/VehicleWheel.h” should be added into .cpp to fix pointers errors

---

<div class="post-metadata">

**Author:** ![MaxBrussow](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MaxBrussow](https://forums.unrealengine.com/u/MaxBrussow)\
**Post date:** [February 21, 2018, 10:16am UTC](https://forums.unrealengine.com/t/change-vehicle-wheel-tire-type-at-runtime/336932/6 "2018-02-21T10:16:29Z")

</div>

I have the same issue as Pirog. The Include also does not work because it :  
Cannot open include file: ‘VehicleWheel.h’: No such file or directory

I really do not understand why this include does not work.  
Help would be really appreciated

---

<div class="post-metadata">

**Author:** ![Gelani](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gelani](https://forums.unrealengine.com/u/Gelani)\
**Post date:** [February 21, 2018, 10:51am UTC](https://forums.unrealengine.com/t/change-vehicle-wheel-tire-type-at-runtime/336932/7 "2018-02-21T10:51:22Z")

</div>

VehicleGame.Build.cs

```
public VehicleGame(ReadOnlyTargetRules Target) : base (Target)
{

    PublicDependencyModuleNames.AddRange(
        new string[] {
            "Core",
            "CoreUObject",
            "Engine",
            "InputCore",
            "PhysX",
            "APEX",
            "PhysXVehicles",
            "PhysXVehicleLib",
            "MessagingRpc",
            "PortalRpc",
            "Networking",
            "Sockets",
            "PortalServices",
            "OnlineSubsystem",
            "OnlineSubsystemUtils",
            "Steamworks",
            "SteamParty",
            "OnlineSubsystemSteam",
		

        }
    );

    PrivateDependencyModuleNames.AddRange(
        new string[] {
            "Slate",
            "SlateCore",
            "OnlineSubsystem",
            "Sockets",
            "Networking",
            "OnlineSubsystemUtils",
            "PhysXVehicles",
            "PhysXVehicleLib",
        }
    );

```

VehicleMovementComponentBoosted4w.h

```
#pragma once
#include "WheeledVehicle.h"
#include "WheeledVehicleMovementComponent.h"
#include "WheeledVehicleMovementComponent4W.h"
#include "VehicleMovementComponentBoosted4w.generated.h"

```

VehicleMovementComponentBoosted4w.cpp

```
#include "VehicleGame.h"
#include "Pawns/VehicleMovementComponentBoosted4w.h"

#if WITH_PHYSX
//For Scene Locking using Epic's awesome helper macros like SCOPED_SCENE_READ_LOCK
#include "Runtime/Engine/Private/PhysicsEngine/PhysXSupport.h"
#include "PhysicsPublic.h"
#include "PhysXPublic.h"
#include "Runtime/Engine/Private/PhysicsEngine/PhysXSupport.h"
    
#endif //WITH_PHYSX
```

---

<div class="post-metadata">

**Author:** ![MaxBrussow](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MaxBrussow](https://forums.unrealengine.com/u/MaxBrussow)\
**Post date:** [February 21, 2018, 11:05am UTC](https://forums.unrealengine.com/t/change-vehicle-wheel-tire-type-at-runtime/336932/8 "2018-02-21T11:05:02Z")

</div>

Thank you very much, i forgot to add the Public and Private Dependencies.  
Now it is working properly!
