FBodyInstance::SetObjectType doesn't work
I was finding a way to change collision channels of rigid bodies on the fly and found a function called FBodyInstance::SetObjectType that looked like the one. I tried but it didn't work.
Here's how I did the test: I created a project of the ThirdPerson template and added a Box Collision component to the player character and set the collision channel of the box to Vehicle and made it overlap only PhysicsBody. Then I created another character with PhysicsAsset and set up the collision data of the character mesh that it overlaped Vehicle and its collision channel was PhysicsBody. And then I wired up a PrintText node in the box' graph for OnComponentBeginOverlap event so that whenever the box touched the character with PhysicsAsset I would got on-screen messages.
Once I made sure the setup worked, I started the real test: I changed the collision channel of the character mesh with PhysicsAsset to Pawn and called GetMesh()->SetAllBodiesCollisionObjectType(ECC_PhysicsBody) in BeginPlay() function on the character with PhysicsAsset since internally it calls FBodyInstance::SetObjectType. However, the overlap event wasn't triggerd and I didn't get any messages as the previous test. So I don't think FBodyInstance::SetObjectType really works. I hope I am wrong and someone can share how to use this function properly.
asked Dec 09 '16 at 02:26 PM in C++ Programming
Follow this question
Once you sign in you will be able to subscribe for any updates here