Expose Var to bp

Hey guys,
im breaking my head over this one, so:
im trying to set a float from a movement component in bp, sadly it isnt exposed to bp.
So i figured maybe i could make a child class of that movement component and expose it somehow.
ive googled and tried to much stuff and for so long, its way to late any my brain basically stopped working ( sorry for spelling mistakes)

My question is:
Can you expose a value to bp from an inherited variable?

It is a value you can just edit in the editor when clicking on the movement component

What specifically is the movement component you’re referring to, and the property you want to expose?

VehicleMovementComponentW4, the clutchstrength under transmission setup.
Want to build a quick driving simulator (vr and wheel with stickshift) since the driving schools here are locked down and my car is a piece of junk thats probably gonna break down if my girlfriend stalls the engine more. Got everything basically done except for the clutch. thank you for helping btw!

Its in the engine folder: Ue4_(engineversion) \ Engine \ Plugins \ Runtime \ PhysXVehicles \Source \ PhysXVehicles \ Public

Ok, so looking at ClutchStrength, that is a public property of the FVehicleTransmissionData struct, and the UWheeledVehicleMovementComponent4W has a FVehicleTransmissionData public property called TransmissionSetup. It is marked as EditAnywhere, but it isn’t exposed to blueprints – you’re looking for it to either be marked as BlueprintReadWrite or have a function that is BlueprintCallable that gets you at the data you’re after. So the answer is, yes. You should be able to expose this to BPs by inheriting from the UWheeledVehicleComponent4W and creating functions for access. Something like:

In .h

class NAMEOFMY_API UMyVersionOfTheComponent : public UWheeledVehicleMovementComponent4W

   UFUNCTION(BlueprintCallable, Category = "MyComponentFunctions")
   float GetClutchStrength();

   UFUNCTION(BlueprintCallable, Category = "MyComponentFunctions")
   void SetClutchStrength(float Value);

in .cpp

float UMyVersionOfTheComponent::GetClutchStrength()
   return TransmissionSetup.ClutchStrength;

void UMyVersionOfTheComponent::SetClutchStrength(float Value)
   TransmissionSetup.ClutchStrength = Value;

That should get you what you’re after. If you’d like access to the TransmissionSetup as a whole so you can set values in it directly, you could always do something like:


UFUNCTION(BlueprintCallable, Category="MyComponentFunctions")
FVehicleTransmissionData* GetTransmissionSetup()


FVehicleTransmissionData* UMyVersionOfTheComponent::GetTransmissionSetup()
   return &TransmissionSetup;

Then you should be able to set whatever values in that struct you want through that pointer. Lemme know if that works for you. If it doesn’t I may have overlooked something. Best of luck.

Thanks for the amazing help, will try it right away and will get back to you.

Well it seems to have worked. Need to redo my whole pawn but quick tested by getting the clutch strength and printing it. and before every test started, changed the clutchstrength from the component settings tab, works flawlessly for now. Will rework the pawn again(with rpm gauge and the whole pain of setting up vehicles in ue4(not sure if still today tomorrow for sure tho)) Im so glad you decided to help, you make this community a great place to learn and understand and grow. I hope you stay healthy and keep being the good person as you are!

ive just tried it and sadly it does read the actual value, but when setting the value it still reads it (how the input is) but it doesnt have anyeffect on the component, ive noticed it says “catergory = setup” maybe the component asks for that var only when being setup once?

To clarify:
input clutch node -> set clutch strength (since unpressed outputs 1 and pressed outputs 0 its fine)

event tick-> MyVersionOfTheComponent -> get clutchstrength -> print string
works but when setting clutch strength to 0 (in component settings) the vehicle doesnt move nomatter what gear (as it should) and get strength puts out 0
setting it to 1(in component settings) makes the vehicle move (as it should) and get strength puts out 1 (as it should)

But setting it runtime via analog clutch pedal or simply button still gets the me right value but doesnt actually effect the transmission
Ive tripple checked now it that is even the value i need and im 100% certain that i need it. It behaves exactly the way a real clutch would. I simply dont understand why they bother to put in that setting and not make it bp accessable or even runtime.

I’m looking through the UWheeledVehicleMovementComponent4W code right now. Yeah, ClutchStrength has Category = Setup, but that’s just a category heading that the property will appear in when viewed in the details panel.

Looking at where the ClutchStrength property is used in the .cpp, I notice that there’s a function called UpdateTransmissionSetup(const FVehicleTransmissionData& NewTransmissionSetup); Maybe this needs to be added to your SetClutchStrength() function:

void UMyVersionOfTheComponent::SetClutchStrength(float Value)
   TransmissionSetup.ClutchStrength = Value;

Does that make your changes take effect, by chance?

Just tried it out sadly that didnt fix it :confused: cpp looks like that:

// Fill out your copyright notice in the Description page of Project Settings.

#include "VehicleMovementClutchComponent.h"

float UVehicleMovementClutchComponent::GetClutchStrength()
return TransmissionSetup.ClutchStrength;

void UVehicleMovementClutchComponent::SetClutchStrength(float Value)
TransmissionSetup.ClutchStrength = Value;

or did i do something wrong?

just checked the cpp and found that the clutch strength doesnt get updated:

void UWheeledVehicleMovementComponent4W::UpdateTransmissionSetup(const FVehicleTransmissionData& NewTransmissionSetup)
if (PVehicleDrive)
PxVehicleGearsData GearData;
GetVehicleGearSetup(NewTransmissionSetup, GearData);

PxVehicleAutoBoxData AutoBoxData;
GetVehicleAutoBoxSetup(NewTransmissionSetup, AutoBoxData);

PxVehicleDrive4W* PVehicleDrive4W = (PxVehicleDrive4W*)PVehicleDrive;
#endif // WITH_PHYSX

Only thing that does get updated is the autogearbox setting(and maybe the current gear/ratio?)If so maybe there could be a work around changing the gear ratio depending on the clutch rl angle. is there some way to maybe call that update function and add the clutch strength in somehow?
(btw you might have already guessed but im new to c++ know basics of java thats basically it.)

Ok, disclaimer time: In all honesty, I don’t know a whole hell of a lot about this particular component. Is there a workaround to get the change in clutch strength to take at runtime? I’m not sure. However, that doesn’t mean you can’t try – the only thing you lose is time. And, at the same time, maybe gain a little more familiarity with how this thing is put together. But this is what I see:

Looking further in the .cpp where ClutchStrength is utilized, I see that SetupDriveHelper() is called from within SetupVehicleDrive(). DriveData (which is a PxVehicleDriveSimData4W) is passed in to this function. In the function itself I see:

PxVehicleClutchData ClutchSetup;
ClutchSetup.mStrength = M2ToCm2(VehicleData->TransmissionSetup.ClutchStrength);

VehicleData in the above is the UWheeledVehicleMovementComponent4W itself.

Later in the SetupVehicleDrive(), DriveData is passed to PVehicleDrive4W->setup(), and then at the end, PVehicleDrive4W is cached as both PVehicle and PVehicleDrive (why this is, I’m not sure).

Looking at the file that holds the declaration of PVehicleDrive4W’s setup() function (in PxVehicleDrive4W.h), it looks like there is nothing to provide an update to the drive data at runtime – it’s either create (allocate and setup a vehicle) or setup (set up an existing vehicle).

Like I said, you may want to play around and see if you can bend things to your will (i.e. copy code from the functionality I’ve pointed out above into your SetClutchStrength() code) to see if you can get it to work. But from what I’m seeing, this wasn’t intended for on-the-fly data changes. I’m sorry, man.

I do urge anyone who comes across this post and knows more about this component than I do to chime in if they know another way.