public void ForceMovement(Vector3 targetPosition, Vector2 targetLook, bool release) { forcedPosition = targetPosition; forcedLook = targetLook; while (forcedLook.x < 0) { forcedLook.x += 360; } while (forcedLook.x >= 360) { forcedLook.x -= 360; } forcedMove = true; cutsceneLock = true; CameraController camCon = Camera.main.GetComponent <CameraController>(); if (camCon != null) { camCon.CutsceneLock = true; } ChracterInteract charInteract = GetComponent <ChracterInteract>(); if (charInteract != null) { charInteract.CutsceneLock = true; } float hAngle = forcedLook.x - camCon.getLook().x; if (hAngle == 0) { forcedTurn = 0; } else if (hAngle > 0) { if (hAngle >= 180) { forcedTurn = -1; } else { forcedTurn = 1; } } else { if (hAngle <= -180) { forcedTurn = 1; } else { forcedTurn = -1; } } forceRelease = release; }
// Use this for initialization void Start() { ChracterInteract characterIntercat = GameObject.FindGameObjectWithTag("Player").GetComponent <ChracterInteract>(); characterIntercat.PermitAction(0, false); characterIntercat.PermitAction(1, false); characterIntercat.PermitAction(2, false); characterIntercat.PermitAction(3, false); characterIntercat.PermitAction(4, true); }
public void CutsceneRelease() { CameraController camCon = Camera.main.GetComponent <CameraController>(); ChracterInteract charInteract = GetComponent <ChracterInteract>(); cutsceneLock = false; if (camCon != null) { camCon.CutsceneLock = false; } if (charInteract != null) { charInteract.CutsceneLock = false; } }
// Use this for initialization void Start() { lastFrameRot = new Vector3(0, 0, 0); for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(i).tag == "Player") { player = transform.GetChild(0).gameObject; player.GetComponent <CharacterMovement>().CutsceneLock = true; player.GetComponentInChildren <CameraController>().CutsceneLock = true; ChracterInteract characterIntercat = player.GetComponent <ChracterInteract>(); characterIntercat.PermitAction(0, false); characterIntercat.PermitAction(1, false); characterIntercat.PermitAction(2, false); characterIntercat.PermitAction(3, false); characterIntercat.PermitAction(4, true); break; } } }
// Update is called once per frame void Update() { if (player) { lastFrameRot = player.transform.localEulerAngles; if (PlayState.Paused == GetComponent <PlayableDirector>().state) { player.transform.parent = null; player.GetComponent <CharacterMovement>().CutsceneLock = false; player.GetComponentInChildren <CameraController>().CutsceneLock = false; ChracterInteract characterIntercat = player.GetComponent <ChracterInteract>(); characterIntercat.PermitAction(0, true); characterIntercat.PermitAction(1, true); characterIntercat.PermitAction(2, true); characterIntercat.PermitAction(3, true); characterIntercat.PermitAction(4, false); Destroy(gameObject); //Debug.Log("Thi"); } } }
public void Start() { tutorialUI = TutorialUI.instance; ci = player.GetComponent <ChracterInteract>(); }
private void Forcing() { transform.position = Vector3.MoveTowards(transform.position, forcedPosition, 0.2f); CameraController camCon = Camera.main.GetComponent <CameraController>(); ChracterInteract charInteract = GetComponent <ChracterInteract>(); Vector2 newLook = camCon.getLook(); float turnSpeed = 4 * 60 * Time.deltaTime; newLook.y = Mathf.MoveTowards(newLook.y, forcedLook.y, turnSpeed); if (newLook.x == forcedLook.x) { forcedTurn = 0; } newLook.x += forcedTurn * turnSpeed; if (newLook.x >= 360) { newLook.x -= 360; } else if (newLook.x < 0) { newLook.x += 360; } if (forcedTurn == 1) { if (forcedLook.x >= 360 - turnSpeed) { if (newLook.x < turnSpeed) { newLook.x = forcedLook.x; } } if (newLook.x > forcedLook.x) { if (newLook.x - forcedLook.x <= turnSpeed) { newLook.x = forcedLook.x; } } } else if (forcedTurn == -1) { if (forcedLook.x <= turnSpeed) { if (newLook.x > 360 - turnSpeed) { newLook.x = forcedLook.x; } } if (newLook.x < forcedLook.x) { if (forcedLook.x - newLook.x <= turnSpeed) { newLook.x = forcedLook.x; } } } newLook.y = Mathf.Clamp(newLook.y, -90, 90); camCon.transform.localRotation = Quaternion.AngleAxis(-newLook.y, Vector3.right); // New ghetto solution transform.localRotation = Quaternion.AngleAxis(newLook.x, transform.up); camCon.setLook(newLook); if (transform.position == forcedPosition && camCon.getLook() == forcedLook) { forcedMove = false; if (forceRelease) { cutsceneLock = false; camCon.CutsceneLock = false; charInteract.CutsceneLock = false; } } }