/// <summary> ///左边的墙撞到了人,人不能继续左移 /// </summary> /// <param name="other"></param> public void OnTriggerEnter(Collider other) { if ("MeDisplay(Clone)" == other.gameObject.name) //碰到了玩家 { //Debug.Log(Time.time + "left 人和墙壁的夹角:" + ToolsFunction.IntersectionAngle(this.gameObject, other.gameObject)); int angle = ToolsFunction.IntersectionAngle(this.gameObject, other.gameObject); if (ToolsFunction.BetweenTwo(angle, -5, 5) || ToolsFunction.BetweenTwo(angle, 175, 185)) //表示MeDisplay不是偏移过去的 { State.OFFSET_CURRENT = State.OFFSET_LEFT; } else { State.OFFSET_IDLE = true; //则最终为idle,旋转的时候解锁,但是left什么时候解锁?? other.transform.position -= 0.1f * ToolsFunction.Toward(other.gameObject); } } }
/// <summary> /// 右边的墙壁碰到了人,不能继续右移 /// </summary> /// <param name="other"></param> public void OnTriggerEnter(Collider other) { if ("MeDisplay(Clone)" == other.gameObject.name) //碰到了玩家 { //要判断当前两个对象的夹角 Debug.Log(Time.time + "right 人和墙壁的夹角:" + ToolsFunction.IntersectionAngle(this.gameObject, other.gameObject)); int angle = ToolsFunction.IntersectionAngle(this.gameObject, other.gameObject); if (ToolsFunction.BetweenTwo(angle, -5, 5) || ToolsFunction.BetweenTwo(angle, 175, 185)) //表示MeDisplay不是偏移过去的 { State.OFFSET_CURRENT = State.OFFSET_RIGHT; } else //表示跑步撞到墙上的, { //向后偏移 State.OFFSET_IDLE = true; other.transform.position -= 0.1f * ToolsFunction.Toward(other.gameObject); } } }