Changing class defaults (Chaos Vehicles) at runtime

It appears that the stats of Chaos Vehicles based vehicles are all in class defaults and private. I can’t be the only one who wants to add a vehicle upgrade system? How are you meant to get around this?

I am not super familiar with the Chaos Vehicles, but are you not able to create a Chaos Vehicles-based vehicle class and expose the necessary variables as public? This will allow you to make changes to the vehicle’s stats through blueprint scripting.

Keep in mind that this will likely require a good understanding of the Unreal Engine, C++, and blueprint scripting, and it’s important to properly test the changes you make to ensure the physics simulation remains stable.

2 Likes

Cars inherit from WheeledVehiclePawn, which has a ChaosWheeledVehicleMovementComponent with all sorts of stats that are class defaults and setters for a (too) small subset of them. I don’t immediately see a way to expose variables as public via blueprint when they are private in the component you are forced to use. :thinking: Am I missing something?

I was hoping to avoid having to dive into the C++ source files and figure out how to change some class defaults (which I’m assuming are static properties) to instanced variables, but it may be the only option.

Oh well, let’s bite the bullet and learn some C++ then…

1 Like

There are a few ways to expose private variables to Blueprint:

  1. You can create a Blueprint-callable function in the component that gets or sets the value of the private variable. This function can then be called from Blueprint.
  2. You can use the UPROPERTY(EditAnywhere, BlueprintReadWrite) macro to expose the variable to Blueprint. This macro can be applied to class variables to make them editable in the editor and accessible through Blueprint.
  3. You can create a new variable in the parent class (in this case, the WheeledVehiclePawn class) that is exposed to Blueprint and use it to set or get the value of the private variable in the component.
  4. You can use a custom EventDispatcher in the component to notify blueprints when the variable changes, and allow them to read the variable value.

I might have gotten something above incorrect, but those are a few of the methods I’d recommend.

1 Like

Hello friend, I’m Brazilian, I didn’t understand your explanation. Can you explain me better how to do this?