【发布时间】:2020-06-04 14:59:16
【问题描述】:
我想捡起一只绵羊并将其移到玩家的头部,方法是将它作为一个空游戏对象的父级。这一切都很好,除了绵羊没有移动到头部而是在养育时保持在他的位置。有什么方法可以仅通过它的对撞机参考来改变绵羊的位置吗?对不起,如果这是一个菜鸟问题,我是初学者,我希望你能帮助我!提前致谢!
if (Input.GetKey(KeyCode.Space)) {
if (targetTime <= 0.0f)
{
targetTime = 2f;
if (inhand == true)
{
InHand.transform.SetParent(null);
inhand = false;
Debug.Log("Abgelegt");
}
else
{
Collider2D[] sheepsinrange = Physics2D.OverlapCircleAll(attackPos.position, attackRange, whatIsEnemies);
if (sheepsinrange.Length > 0)
{
InHand = sheepsinrange[0];
InHand.transform.SetParent(sheepPos);
inhand = true;
Debug.Log(sheepsinrange + " aufgenommen");
}
}
}
}
}
【问题讨论】:
标签: c# unity3d gameobject