Hi,
I decided to port my project to C++, because, blue print can get you so far, and I’m learning to love UE4!
So,
I come across “FPrimitiveComponentPostPhysicsTickFunction” and ooh this seems interesting, is this where all the physics simulations goes? So my Pawn is a physics box, and I will ray cast from 4 points to make it hover. Will I put ray trace, add force, add torque, in this function?
Here is my implementation:
// Called when the game starts or when spawned
void AMyPawn::BeginPlay()
{
Super::BeginPlay();
//i am the server
if (Role > ROLE_Authority)
{
//if you are the server, then simulate physics
PhysicsBoxPrimitive->SetSimulatePhysics = true;
}
if (IsLocallyControlled)
{
//if you are locally controlled, the server will spawn this for you, so you do it locally
//and make sure have authority over your own hover car
//this was client can move locally, and have server correct client every frame
PhysicsBoxPrimitive->SetSimulatePhysics = true;
//Tick function that calls UPrimitiveComponent::PostPhysicsTick - PhysicsBoxPrimitive inherits UPrimitiveComponent
FPrimitiveComponentPostPhysicsTickFunction* FtickF;
FtickF->Target = PhysicsBoxPrimitive;
PhysicsBoxPrimitive->PostPhysicsTick(*FtickF, &AMyPawn::FixedUpdate);
}
}
void AMyPawn::FixedUpdate()
{
//apply force every fixed frame
}
Maybe I’m wrong, and delusional. If I am please let me know.
But is this correct, VS says no, because of →
PhysicsBoxPrimitive->PostPhysicsTick(*FtickF, &AMyPawn::FixedUpdate);
It’s been implemented wrong?
Please let me know,