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?