I am using the "distance Joint 2d" component for dragging an object.
it seems that although the "Max distance Only" check box is selected if moving fast the parent object , the child object distance grows to be more than defined in the "Distance" param.
why?
//Parent movement code
using UnityEngine;
using System.Collections;
public class moveDude1 : MonoBehaviour {
Vector2 current_position;
// Use this for initialization
void Start () {
current_position = transform.position;
}
// Update is called once per frame
void Update () {
if (Input.GetKey ("right")) {
//transform.Translate(1,0,0);
transform.position = new Vector3 (transform.position.x + 1, current_position.y, transform.position.z);
} else if (Input.GetKey ("left")) {
//transform.Translate(-1,0,0);
transform.position = new Vector3 (transform.position.x - 1, current_position.y, transform.position.z);
//} else {
// transform.position = new Vector3 (transform.position.x, current_position.y, transform.position.z);
}
}
}
↧