I’m using UE4.16.3 but this problem comes from 4.15,
What I did
I have created a child of pawn class, called it vehicle and then created another child from that and called it plane. I then created sub-objects to populate the blueprint actor such as a camera, skeletal mesh and etc.
Problem:
I want to enable physics and gravity for the plane because the came should realistically simulate drag, lift by using thruster as shown in: Create a Space Flight Physics Simulator in Unreal Engine 4 - YouTube. But my blueprint actor is ignoring gravity, force.
What I tried
-
Changing Root from skeletal mesh component to scene component.
-
Changing physical asset (And yes it simulates perfectly in Physics Assets Previewer)
-
Change Collision to (Vehicle, Pawn, BlockALL)
-
In constructor of airplane:
- getVehicleBody()->SetSimulatePhysics(true);
- getVehicleBody()->SetAllBodiesBelowSimulatePhysics(FName(“Root”), true, true);
- getVehicleBody()->SetEnableGravity(true);
- getVehicleBody()->SetMobility(EComponentMobility::Movable);
- getVehicleBody()->WakeAllRigidBodies();
- getVehicleBody()->WakeRigidBody();
What worked
Creating the entire Plane in blueprint with the exact same settings works perfectly so i’m guessing the problems lies within the way I have used the c++ class.
Header File of Vehicle
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Vehicle")
class USceneComponent* root;
// Body of the vehicle
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Vehicle")
class USkeletalMeshComponent* vehicleBody;
// Spring arm that will offset the camera
UPROPERTY(Category = Camera, EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
class USpringArmComponent* SpringArmIn;
// Camera component that will be our viewpoint
UPROPERTY(Category = Camera, EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* CameraIn;
Airplane:
Any help will be much appreciated!