Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to teleport a rope
#6
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:

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,
Reply


Messages In This Thread
How to teleport a rope - by HPx___ - 23-01-2024, 06:37 PM
RE: How to teleport a rope - by josemendez - 24-01-2024, 07:56 AM
RE: How to teleport a rope - by HPx___ - 24-01-2024, 09:11 AM
RE: How to teleport a rope - by josemendez - 24-01-2024, 09:53 AM
RE: How to teleport a rope - by HPx___ - 24-01-2024, 11:27 AM
RE: How to teleport a rope - by josemendez - 24-01-2024, 12:01 PM