Add Joint.SetJointLocation for easier joints setup
This commit is contained in:
@@ -89,6 +89,18 @@ void Joint::SetTargetAnchorRotation(const Quaternion& value)
|
||||
}
|
||||
}
|
||||
|
||||
void Joint::SetJointLocation(const Vector3& location)
|
||||
{
|
||||
if (GetParent())
|
||||
{
|
||||
SetLocalPosition(GetParent()->GetTransform().WorldToLocal(location));
|
||||
}
|
||||
if (Target)
|
||||
{
|
||||
SetTargetAnchor(Target->GetTransform().WorldToLocal(location));
|
||||
}
|
||||
}
|
||||
|
||||
void Joint::GetCurrentForce(Vector3& linear, Vector3& angular) const
|
||||
{
|
||||
if (_joint && _joint->getConstraint())
|
||||
|
||||
@@ -36,8 +36,6 @@ public:
|
||||
API_FIELD(Attributes="EditorOrder(0), DefaultValue(null), EditorDisplay(\"Joint\")")
|
||||
ScriptingObjectReference<Actor> Target;
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets the break force. Determines the maximum force the joint can apply before breaking. Broken joints no longer participate in physics simulation.
|
||||
/// </summary>
|
||||
@@ -130,6 +128,13 @@ public:
|
||||
return _joint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the location of the joint by automatically computing local position and target anchor to place a joint at the given location (world-space).
|
||||
/// </summary>
|
||||
/// <remarks>Use this utility to automatically place joint at the given location after setting up joint parent and target.</remarks>
|
||||
/// <param name="location">The joint location to set (world-space).</param>
|
||||
API_FUNCTION() void SetJointLocation(const Vector3& location);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current force applied by the solver to maintain all constraints.
|
||||
/// </summary>
|
||||
@@ -142,8 +147,6 @@ public:
|
||||
/// </summary>
|
||||
void Create();
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a joint gets broken during simulation.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user