unity3d学习记录-放下武器,更改武器的position和rotation
孙健查询了很多资料,发现不能更改直接position的y值,和rotation,但是可以通过下面的代码来实现这个功能
void DropWeapon()
{
//主角手上没有武器了
ishaveweapon = false;
//武器的父目录设置为空
weaponTrans.SetParent(null);
//修改武器的位置
Vector3 vect = weaponTrans.position;
vect.y = 0.06f;
weaponTrans.position = vect;
//修改武器的旋转角度
Vector3 rotationVector3 = transform.rotation.eulerAngles;
rotationVector3.x =90f;
rotationVector3.y += 360f;
weaponTrans.rotation = Quaternion.Euler(rotationVector3);
}
孙健个人博客