我正在尝试构建一个破砖游戏,我想根据球击中球拍的位置来瞄准球。例如,如果球击中桨的右边缘,它应该向右(向上)。假设桨有一个盒子(或胶囊)对撞机,而球有一个球对撞机,我该怎么做?谢谢你的帮助!
我也想得到垫子的速度。下面的代码返回0,有什么想法吗?
function OnTriggerEnter(other:Collider)
{
if(other.rigidbody){
V_pad=other.rigidbody.velocity;
//Here it returns (0,0,0) , also tried other.attachedRigidbody
}
if(other.name=="Pad"){
rigidbody.velocity =
Vector3(rigidbody.velocity.x, Mathf.Abs(rigidbody.velocity.y + V_pad),0);
//this part executes but with V_pad.y=0
}
}