24-01-2024, 12:01 PM
(This post was last modified: 24-01-2024, 12:04 PM by josemendez.)
I'm not sure I entirely understand your code, I think I'm missing some context. You're adding two control points, one at the rope's local zero, and another one at 0,0,1. The tangent for both points is 0,0,-1, which in this case will result in a kink at the start of the rope, should be 0,0,1 (that is, positive Vector3.forward) for the first point:
However your rigidbody is at 2,4,0, so unless your rope transform is *exactly* at 2,4,-1, the rigidbody won't be even close to the end of the rope.
Also note that the following code doesn't make any sense: you're moving the rigidbody transform to a position, then moving it again to the exact same position. Either use transform.position or rigidbody.MovePosition, not both.
Making sure the rope is at 2,4,-1 and removing the call to MovePosition, I've tried your code and it works fine for me (in the video, I'm calling Teleport() upon pressing T in the keyboard):
cheers,
Code:
blueprint.path.AddControlPoint(Vector3.zero, -Vector3.forward, Vector3.forward, Vector3.up, 0.1f, 0.1f, 1, 1, Color.white, "upper");
blueprint.path.AddControlPoint(Vector3.forward, -Vector3.forward, Vector3.forward, Vector3.up, 0.1f, 0.1f, 1, 1, Color.white, "lower");
However your rigidbody is at 2,4,0, so unless your rope transform is *exactly* at 2,4,-1, the rigidbody won't be even close to the end of the rope.
Also note that the following code doesn't make any sense: you're moving the rigidbody transform to a position, then moving it again to the exact same position. Either use transform.position or rigidbody.MovePosition, not both.
Code:
ropeEnd.transform.position = ropeEnd.transform.position + new Vector3(3, 0, 0);
ropeEnd.GetComponent<Rigidbody>().MovePosition(ropeEnd.transform.position); // redundant
Making sure the rope is at 2,4,-1 and removing the call to MovePosition, I've tried your code and it works fine for me (in the video, I'm calling Teleport() upon pressing T in the keyboard):
cheers,