Unity 2d で私のオブジェクトに 1 つの問題があります。ボックス コライダーへの矢印を他の要素に向けて発射すると、それがヒットして子になると、矢印が親 (BOX) の子になり、子が回転し始めます。左右..私は本当に子の左右の回転を無効にしたい..ボックス(親)は以前と同じように回転する必要があります..私はこのようなコードを持っていて、rigidbody2dの矢印がオンになっていますキネマティック モード...
これは矢印のスクリプトです..
{
public float flySpeed = 20f;
private Rigidbody2D arrowBody;
private bool shouldFly;
// Start is called before the first frame update
void Start()
{
shouldFly = true;
arrowBody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
if (shouldFly == true)
{
//make our pin fly
arrowBody.MovePosition(arrowBody.position + Vector2.up * flySpeed * Time.deltaTime);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == "target")
{
shouldFly = false;
transform.SetParent(collision.gameObject.transform);
} else if(collision.tag == "arrow")
{
SceneManager.LoadScene("quickGameOverScene");
}
}
}