i want to be able to pull objects towards the playing and the following code is working fine except when there is an overhang between the player and object
private void FixedUpdate()
{
//Frame-rate independent for physics calculations and anything that runs at fixed rate.
if (_PullAnimationIsPulling && _HitTargetGO)
PullHitTargetGOTowardsPlayersRWrist();
}
public void PullHitTargetGOTowardsPlayersRWrist()
{
if (_DistancePlayerToHitTarget <= _NewDistancePlayerToHitTarget)
{
ClearNewDistancePlayerToHitTarget(); // got there so stop moving
return;
}
Rigidbody rb = _HitTargetGO.transform.GetComponent<Rigidbody>();
const float speed = 60f;
Vector3 direction = _pc._wristR.position - _HitTargetGO.transform.position;
Vector3 movingStep = direction.normalized * speed;
//Debug.Log("PullRopeSMB movingStep=" + movingStep);
rb.AddForceAtPosition(movingStep, _ActiveArrow.transform.position, ForceMode.Impulse);
}
the problem is if i am up on a ledge, i can pull the object towards me but after the effect of the impulse fades away, the object falls back to the ground.
how would i constrain it so it stay stays say a fixed distance from the player?
by the way, _ActiveArrow is a child of the thing i’m pulling (was parented when i hit the thing) and the point at which i want the thing constrained. maybe i can somehow freeze the position of that?
thanks
ops, i meant the title to say constraining it, can’t fix