Question by
SavaGhost · May 31, 2018 at 03:49 PM ·
rigidbody2d2d-physicsmousepositionropemomentum
2D rope attached object has no momentum when swung
Hi guys,
I'm currently trying to make a ball that is attached to a rope (made from 2d hinge joints) keep it's momentum when swung. The rope follows my mouse and when i move it around, i want the ball to have momentum so that i can swing it around like a wrecking ball or a yoyo. Currently the ball doesn't have any velocity or momentum when i swing the rope around.
This is my mouse follow code :
private Vector3 mousePosition;
public float moveSpeed = 0.1f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButton(1)) {
mousePosition = Input.mousePosition;
mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
transform.position = Vector2.Lerp(transform.position, mousePosition, moveSpeed);
}
}
}
Thanks for any help!
game.png
(73.5 kB)
Comment