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"

[C++/VR] Prevent clipping on pick up object

As I understand it, physics constraints are the ideal way to attach a pick-up to a VR controller (Actor) while retaining the inability for the player to make the picked up object from clipping through walls. However when I try to set a constraint to the controller actor, the mesh will not move at all with the controller.

Current code/setup is as follows:

AStaticMeshActor with UPhysicsConstraintComponent and PickUpAble Tag

AVRController Class derived from AActor

I have tried reversing the Actors in the SetConstrainedComponents and the behavior is the same.

 void AVRController::Grab()
 if (m_b_can_pick_up == true)
     if (m_pick_up_actor != nullptr)
     // Works but clips thorough objects. See below video
     //m_pick_up_actor->K2_AttachToActor(this, TEXT("Trigger"), EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, false);
     UPrimitiveComponent* pick_up_actor_cast = Cast<UPrimitiveComponent>(m_pick_up_actor);
     m_pick_up_actor->m_phys_constraint->SetConstrainedComponents(m_vr_controller_mesh, NAME_None, pick_up_actor_cast, NAME_None);

Here is a video of the not desired output https://www.youtube.com/watch?v=0bwknAvh-Us

Product Version: UE 4.21
more ▼

asked Dec 09 '18 at 03:59 PM in VR

avatar image

1 2

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

After a day of testing and looking at other people's code I was able to get the desired effect.

I needed to constrain the two static meshes with m_pick_up_actor->m_phys_constraint->SetConstrainedComponents(m_vr_controller_mesh, NAME_None, m_pick_up_actor->GetStaticMeshComponent(), NAME_None);

I also had to set the following properties on the constraint Stiffness 5000 Damping 500 Contact 10 LinearBreakThreshold 5000000

I also had to disable and enable the LinearBreakThreshold when teleporting. Here is a video of how it looks https://www.youtube.com/watch?v=-YQaTvI5LOY

more ▼

answered Dec 10 '18 at 08:14 AM

avatar image

1 2

avatar image ellishawn Jan 25 '19 at 09:58 PM

Can you post a code snippet of that? I don't see how you set those parameters on the constraint. Is that the constraintInstance? I don't see those parameters on the contraintinstance either...

(comments are locked)
10|2000 characters needed characters left
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