x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Physic actor won't socket on disable physics

Hello Answerhub, I've been attempting to socket an actor which has physics enabled on by disabling the physics then attaching then disabling the physics on detachment.

From all material that I've found online it seems that this should work but despite that, if the physics is not enabled at the start and is enabled at drop, you can pick it up, put it down and then never pick it up again.

If you activate physics from the start, the item will never socket right but will still run through the motions, physics will show as disabled in the details panel and it will show as being attached to the character.

I've tried waiting a frame aswell as going through a wide variety of different API functionality to see if I can get this to work with no luck.

Here is my current code for both my pickup and drop:

 void ACP_Character::BeginUseAction()
 {
 
     if(currentLootBag && !heldLootBag)
     {
 
         if(!hasBag)
         {
 
             //Preventing this being called again
             hasBag = true;
             heldLootBag = currentLootBag;
 
             //Set the collision and physics
             TArray<USceneComponent*> components;
             heldLootBag->GetComponents(components);
             UStaticMeshComponent* meshComponent = Cast<UStaticMeshComponent>(components[1]);
 
             //TODO - Fix issues with being unable to pick up the item once physics are enabled
             heldLootBag->SetActorEnableCollision(false);
             meshComponent->SetSimulatePhysics(false);
             //meshComponent->PutAllRigidBodiesToSleep();
             //meshComponent->RecreatePhysicsState();
 
             //Attach the item to our socket
             const FAttachmentTransformRules attachmentRules(EAttachmentRule::SnapToTarget, true);
             heldLootBag->AttachToComponent(GetMesh(), attachmentRules, FName("BagBone"));
 
             //Return to ensure the loot action is not followed
             return;
 
         }
 
     }
 }

 void ACP_Character::ThrowBagAction()
 {
 
     if(hasBag)
     {
 
         //Detach the item from the socket
         const FDetachmentTransformRules detachRules(EDetachmentRule::KeepWorld, false);
         heldLootBag->DetachFromActor(detachRules);
 
         //Turn the physics and collision back on
         TArray<USceneComponent*> components;
         heldLootBag->GetComponents(components);
         UStaticMeshComponent* meshComponent = Cast<UStaticMeshComponent>(components[1]);
 
         //TODO - Fix issues with being unable to pick up the item once physics are enabled
         heldLootBag->SetActorEnableCollision(true);
         meshComponent->SetSimulatePhysics(true);
         //meshComponent->WakeAllRigidBodies();
         //meshComponent->RecreatePhysicsState();
 
         //Rest values to allow future bags to be picked up
         heldLootBag = nullptr;
         hasBag = false;
     }
 
 }


If anyone at all could help with a fix or advise I would eternally within your debt, this issue has persisted for a while and I've attempted to find an answser on Reddit and the official forums with no results.

Thank you.

Product Version: UE 4.13
Tags:
more ▼

asked Oct 27 '16 at 11:57 AM in C++ Programming

avatar image

WaspSix
8 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

For anyone dealing with this, make the component in your actor that has physics enabled set to the root, no sub component should be dealing with physics.

more ▼

answered Oct 28 '16 at 11:32 PM

avatar image

WaspSix
8 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question