VR Expansion Plugin

Wow, i finally Solved the problem. The problem is actually very important, who will use many components of the collision and switching Phys Simulating

1)When we use SetSimPhys(true) for Root Component in BodyInsrance.cpp



void FBodyInstance::SetInstanceSimulatePhysics(bool bSimulate, bool bMaintainPhysicsBlending)
{
.....
// If we are enabling simulation, and we are the root body of our component, we detach the component 
		if (OwnerComponentInst && OwnerComponentInst->IsRegistered() && OwnerComponentInst->GetBodyInstance() == )
		{
			if (OwnerComponentInst->GetAttachParent())
			{
				OwnerComponentInst->DetachFromComponent(FDetachmentTransformRules::KeepWorldTransform);
			}
			
			if (bSimulatePhysics == false)	//if we're switching from kinematic to simulated
			{
				ApplyWeldOnChildren();  //THISS !!!
			}
		}




void FBodyInstance::ApplyWeldOnChildren()
{
.... Browse all the children
const ECollisionEnabled::Type ChildCollision = ChildBI->GetCollisionEnabled();
				if(ChildCollision == ECollisionEnabled::PhysicsOnly || ChildCollision == ECollisionEnabled::QueryAndPhysics)
				{
					if(UPrimitiveComponent* PrimOwnerComponent = ChildBI->OwnerComponent.Get())
					{
						Weld(ChildBI, PrimOwnerComponent->GetSocketTransform(ChildrenLabels[ChildIdx]));
					}
				}


2)And If U use ChildCollision == ECollisionEnabled::PhysicsOnly || ChildCollision == ECollisionEnabled::QueryAndPhysics type collision of u childComponent
function makes all child bodies => IsValidBodyInstance() = false(kill our PxRigidActor)

  1. creates major problems in the Overlap Events for child Component

4)To solve problem need to set the ChildComponent->BodyInstance.SetCollisionEnabled(ECollisionEnabled::NoCollision, true);
For all Child who used ECollisionEnabled::PhysicsOnly Or ECollisionEnabled::QueryAndPhysics
Before SetSimPhys(true) On RootComponent in InteractiveHybridCollisionWithSweep type, or maybe From other places Where you want to enable Root simulation Or we cant use OnComponentBeginOverlapp for child Component normally

5)When we again SetSimPhys(false) on Root Component You need to return the old collision settings
ChildComponent->BodyInstance.SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics, true); For all child Component Who had it before