I am making a game with a rope swing hero and there are also flying cars and they are moving but my character's spring joint's connected anchor stays fixed at the first click point. It does not moving with car. When i was writing my code, i thought if i reference to connected anchor car's rigidbody's position with update function it should move with car but it did not. Whate should i do? Thanks from now.
And here is my code;
void StartGrapple()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, Mathf.Infinity, isGrappleable))
{
currentGrapplePosition = player.position;
grapplePoint = hit.rigidbody.position;
joint = player.gameObject.AddComponent();
joint.autoConfigureConnectedAnchor = false;
joint.connectedAnchor = grapplePoint += new Vector3(-4, 0, 0);
float distanceFromPoint = Vector3.Distance(player.position, grapplePoint);
joint.maxDistance = distanceFromPoint * 0.5f;
joint.minDistance = distanceFromPoint * 0f;
joint.spring = 60f;
joint.damper = 40f;
joint.massScale = 4.5f;
lr.positionCount = 2;
webShot.Play();
}
}