1 回答
TA贡献1810条经验 获得超4个赞
刀片内:
private Vector3 bladeLastPos;
private void Start(){
bladeLastPos = new Vector3(blade.position.x,blade.position.y,blade.position.z);
}
private void Update()
{
Vector2 v1 = new Vector2(this.transform.position.x, this.transform.position.y);
Vector2 v2 = new Vector2(bladeLastPos.x, bladeLastPos.y);
float maxRange = Vector2.Distance(v1,v2);
RaycastHit2D[] hits = Physics2D.RaycastAll(v1, v2 - v1, maxRange);
for (int i = 0; i < hits.Length; i++)
{
var component = hits[i].transform.GetComponent<ScriptNameInFruitWhereCutIs>();
if (!component.cut)
{
//Cut! use public properties/functions within component
}
}
bladeLastPos = new Vector3(transform.position.x,transform.position.y,transform.position.z);
}
这条线将是中心之间的一条细直线,而不是整个刀片形状留下的完整痕迹。
- 1 回答
- 0 关注
- 144 浏览
添加回答
举报