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"

C++ Pull Constraint

Hello!

I'm tinkering with constraints and I'd like to drag a ball around by a 1-link-chain.

I'm think that the way to do this is to create a constraint between my ball actor and a handle actor. I would then transform the handle actor around, and it would pull the ball around via the constraint.

I currently am getting no visible interaction between my handle and ball.

I'm using Rama's tutorial on constraints (https://wiki.unrealengine.com/Physics_Constraints,_Create_New_Constraints_Dynamically_During_Runtime).

Here's what I have so far to create the constraint:

 //set up the constraint instance with all the desired values
     //
     FConstraintInstance ci;
     SetLinearLimits(ci, false, 0, 0, 0, 0);
     SetAngularLimits(ci, 0, 0, 0, 90, 90, 90);
 
     //New Object
     m_constraint_component = NewObject<UPhysicsConstraintComponent>(Mesh);
     if (!m_constraint_component)
     {
         //UE_LOG constraint UObject could not be created!
         return;
     }
 
     //~~~~~~~~~~~~~~~~~~~~~~~~
     //Set Constraint Instance!
     m_constraint_component->ConstraintInstance = ci;
     //~~~~~~~~~~~~~~~~~~~~~~~~
 
     //Attach to Root!
         m_constraint_component->AttachTo(Mesh, NAME_None, EAttachLocation::SnapToTarget);
 
     //~~~ Init Constraint ~~~
         m_constraint_component->SetConstrainedComponents(Mesh, NAME_None, m_constraint_target, NAME_None);

And here is how I'm moving the handle around:

     //Set World Location
     m_constraint_target->SetWorldLocation(location);

Any ideas/links?

Product Version: Not Selected
Tags:
more ▼

asked Nov 21 '14 at 05:18 AM in C++ Programming

avatar image

viperld
20 8 9 12

avatar image viperld Nov 21 '14 at 05:34 AM

I read this post (https://answers.unrealengine.com/questions/25182/physics-constrain-to-axis-in-c.html).

I believe it's saying in the method SetConstrainedComponents(), my handle should come first, then my ball:

 //~~~ Init Constraint ~~~
          m_constraint_component->SetConstrainedComponents(m_constraint_target, NAME_None,Mesh, NAME_None);

This still doesn't show me any interaction.

However! If I don't initialize my FConstraintInstance, the ball flops around lol. If I wanted no limits/locks on my constraint, how should I initialize it? 0's don't seem to do the trick.

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

1 answer: sort voted first

Thats because you set everything to free. So it is basically no constraint. Set the zeros to 2. Better read ramas article again

more ▼

answered Oct 05 '15 at 09:25 PM

avatar image

MykonCodes
96 8 16 26

(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