I am making a wheeled vehicle using the USimpleWheeledVehicleMovementComponent. I am trying to follow the example wheeled vehicle where you can find this code:
UWheeledVehicleMovementComponent4W* Vehicle4W = CastChecked<UWheeledVehicleMovementComponent4W>(GetVehicleMovement());
check(Vehicle4W->WheelSetups.Num() == 4);
Vehicle4W->WheelSetups[0].WheelClass = URoboPuzzlerWheelFront::StaticClass();
Vehicle4W->WheelSetups[0].BoneName = FName("Wheel_Front_Left");
Vehicle4W->WheelSetups[0].AdditionalOffset = FVector(0.f, -12.f, 0.f);
Vehicle4W->WheelSetups[1].WheelClass = URoboPuzzlerWheelFront::StaticClass();
Vehicle4W->WheelSetups[1].BoneName = FName("Wheel_Front_Right");
Vehicle4W->WheelSetups[1].AdditionalOffset = FVector(0.f, 12.f, 0.f);
Vehicle4W->WheelSetups[2].WheelClass = URoboPuzzlerWheelRear::StaticClass();
Vehicle4W->WheelSetups[2].BoneName = FName("Wheel_Rear_Left");
Vehicle4W->WheelSetups[2].AdditionalOffset = FVector(0.f, -12.f, 0.f);
Vehicle4W->WheelSetups[3].WheelClass = URoboPuzzlerWheelRear::StaticClass();
Vehicle4W->WheelSetups[3].BoneName = FName("Wheel_Rear_Right");
Vehicle4W->WheelSetups[3].AdditionalOffset = FVector(0.f, 12.f, 0.f);
it looks like all this class does to setup wheels is set the WheelSetups array. I do a very similar operation in my init function:
header
class PUZZLER_API Aprogramatic_vehicle_c : public APawn
{
GENERATED_BODY()
public:
// Sets default values for this pawn's properties
Aprogramatic_vehicle_c();
protected:
UPROPERTY(Category = Vehicle, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
USimpleWheeledVehicleMovementComponent* movement;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UFUNCTION(BlueprintCallable)
USimpleWheeledVehicleMovementComponent* initRobot();
}
cpp
movement->WheelSetups.Reserve(abs.wheels.Num());
movement->WheelSetups.SetNum(abs.wheels.Num());
// wheels must be in the actors array FIRST to allow bp to work
for (int32 i = 0; i < abs.wheels.Num(); i++)
{
movement->WheelSetups[i].WheelClass = wheelMap[abs.wheels[i].physicsName];
movement->WheelSetups[i].BoneName = FName(*abs.wheels[i].boneName);
movement->WheelSetups[i].AdditionalOffset = FVector(0, 0, 0);
actorsToCreate.Add(abs.wheels[i].meshName);
wheelSocketNames.Add(abs.wheels[i].boneName);
// NOTE: you cant spawn instances of blueprints in C++, so the spawning of wheels will
// need to be done in blueprint
}
movement->RecreatePhysicsState();
However, when I then go to drive the wheels in blueprint, it appears there are no wheels. Printing out the mass and wheels array length in blueprint I can see that both are 0. Its almost as if the movement component in blueprint is a wholly different instance than in C++. Does anyone know what is going on here and how I can drive the wheels?