new void Update() { if (target == null) { return; } else { if (enter) { Vector2 targetPos = new Vector2(target.transform.position.x, target.transform.position.z); Vector2 thisPos = new Vector2(colPoint.x, colPoint.z); currentDist = Vector2.Distance(thisPos, targetPos); if (currentDist > maxDist) { if (turnable) { //cam.setTargetY (saveY + angleY, 0.2f); cam.setTargetY(angleYin, 0.2f); turnable = false; } } else { turnable = true; float y = (currentDist * angleYin) / maxDist; //cam.setTargetY (saveY + y, 0.5f); cam.setTargetY(y, 0.5f); } } else { Vector2 targetPos = new Vector2(target.transform.position.x, target.transform.position.z); Vector2 thisPos = new Vector2(colPoint.x, colPoint.z); currentDist = Vector2.Distance(thisPos, targetPos); if (currentDist > maxDist) { if (turnable) { //cam.setTargetY (saveY - angleY, 0.2f); cam.setTargetY(angleYin, 0.2f); turnable = false; target = null; controller.NextLastTrigger(level.locationName); } } else { turnable = true; float y = (currentDist * angleYin) / maxDist; //cam.setTargetY (saveY - y, 0.5f); cam.setTargetY(y, 0.5f); } } } }
void OnTriggerEnter(Collider other) { if (!enable) { return; } if (other.tag == "Player") { CalculatePos(other.transform.position); if (direction > 0 && target == null) { float eulerX = cam.pivotX.transform.localEulerAngles.x; while (eulerX > 180.0f) { eulerX -= 360.0f; } activated = true; if (requireEntryAngle && (Mathf.Abs(activateEntryAngle - eulerX) > THRESHOLD)) { activated = false; return; } target = other.gameObject; saveX = eulerX; colPoint = other.gameObject.transform.position; ds.storeFloatValue(this.gameObject.name + level.locationName + "SaveX", saveX); ds.storeFloatValue(this.gameObject.name + level.locationName + "pointX", colPoint.x); ds.storeFloatValue(this.gameObject.name + level.locationName + "pointY", colPoint.y); ds.storeFloatValue(this.gameObject.name + level.locationName + "pointZ", colPoint.z); ds.storeBoolValue(this.gameObject.name + level.locationName + "HaveTarget", true); controller.SaveLastTrigger(this.gameObject, level.locationName); } if (direction < 0 && target != null) { cam.setTargetX(saveX, 1); target = null; ds.storeBoolValue(this.gameObject.name + level.locationName + "HaveTarget", false); controller.NextLastTrigger(level.locationName); } } }
void OnTriggerEnter(Collider other) { Debug.Log("<color=yellow>SetCameraFollowDirection</color>"); if (other.tag == "Player") { CalculatePos(other.transform.position); if (direction > 0 && target == null) { float eulerY = cam.pivotY.transform.localEulerAngles.y; while (eulerY > 180.0f) { eulerY -= 360.0f; } activated = true; if (requireEntryAngle && (Mathf.Abs(activateEntryAngle - eulerY) > THRESHOLD)) { activated = false; return; } target = other.gameObject; saveY = eulerY; colPoint = other.gameObject.transform.position; ds.storeFloatValue(this.gameObject.name + level.locationName + "SaveY", saveY); ds.storeFloatValue(this.gameObject.name + level.locationName + "pointX", colPoint.x); ds.storeFloatValue(this.gameObject.name + level.locationName + "pointY", colPoint.y); ds.storeFloatValue(this.gameObject.name + level.locationName + "pointZ", colPoint.z); ds.storeBoolValue(this.gameObject.name + level.locationName + "HaveTarget", true); controller.SaveLastTrigger(this.gameObject, level.locationName); } if (direction < 0 && target != null) { cam.setTargetY(saveY, 1); target = null; ds.storeBoolValue(this.gameObject.name + level.locationName + "HaveTarget", false); controller.NextLastTrigger(level.locationName); } } }