private void Start() { rb = GetComponent <Rigidbody>(); if (PlayerPrefs.HasKey("Especial+Area")) { int ctrl = PlayerPrefs.GetInt("Especial+Area"); if (ctrl == 1) { vortex = vortexUp1; } else { vortex = vortexUp2; } } DOTweenModulePhysics.DOJump(rb, endLine, 2, 1, 0.8f); }
void OnTriggerEnter(Collider other) { //if (!isTrapTriggered) //{ if (other.gameObject.tag == "Trap" || other.gameObject.tag == "turningTrap" || other.gameObject.tag == "loopTrap") { // playerRB.transform.DOPunchPosition(new Vector3(0, 0, 100f * Time.deltaTime), 1, 5, 1, false); //playerRB.transform.DOPunchRotation(new Vector3(0, 0, 100f * Time.deltaTime), 1, 10, 1); // isTrapTriggered = true; // trapInt_CurrentNode = script.CurrentNode; /* player.GetComponent<Animator>().enabled = false; * playerRB.detectCollisions = true; * playerRB.DOJump(PathNode[(script.CurrentNode) - 2].transform.position, 0.75f, 2, 0.315f, false).SetEase(script.anim_ease) * * .OnStart(() => * { * * script.trapCollided = false; * pathFollower.GetComponent<PathFollower>().CheckNode(); * script.trapCollided = true; * * }) * .OnPlay(()=> { * * script.CurrentNode--; * * } * * ) * * .OnComplete(() => * { * * pathFollower.GetComponent<PathFollower>().CheckNode(); * script.trapCollided = false; * }); * * isCollided = true;*/ script.isGrounded = false; pathFollower.GetComponent <PathFollower>().enabled = false; ragdollActivate.SetActiveRagdollPhysics(true); playerRB.AddForce(new Vector3(Random.Range(-4000f, -3000), 0, Random.Range(-4000f, 4000f)) + new Vector3(0, 4000f, 0)); playerRB.AddTorque(new Vector3(0, 100f, 0)); if (playerRB.velocity == Vector3.zero) { Debug.Log("velocity ifine girdi."); StartCoroutine(SpawnAtLastCheckpoint()); } //playerRB.AddForce(-transform.forward*4000f+ new Vector3(0,4000f,0)); } else if (other.gameObject.tag == "Jumper") { var meshJumper = other.gameObject.GetComponentInChildren <MeshRenderer>(); var meshJumperY = meshJumper.bounds.size.y; // CALCULATION OF THE COMPRESS RATIO var meshCompressDiff = (meshJumperY) - (meshJumperY * 0.2f); // var meshOriginalScaleY = other.gameObject.transform.localScale.y; var meshCompressedScaleY = other.gameObject.transform.localScale.y * 0.2f; var playerRBmoveInY = meshCompressDiff; // INIT DIFFERENCE TO MOVEMENT IN Y FOR RB var playerOriginPosY = playerRB.transform.position.y; var playerMoveToInY = playerOriginPosY - playerRBmoveInY; var jumperRB = other.GetComponent <Rigidbody>(); var originY = other.gameObject.transform.localScale.y; // other.gameObject.transform.DOScaleY(0.398f,0.35f).OnComplete(()=> { }); pathFollower.GetComponent <PathFollower>().enabled = false; Sequence jumperSeq = DOTween.Sequence(); if (!jumperFlag) { jumperSeq .Append(other.gameObject.transform.DOScaleY(meshCompressedScaleY, 0.15f).SetEase(Ease.OutQuart)) .Join(playerRB.DOMoveY(playerMoveToInY, 0.15f).SetEase(Ease.OutQuart)) .Append(other.gameObject.transform.DOScaleY(meshOriginalScaleY, 0.12f).SetEase(Ease.InQuart)) .Join(playerRB.DOMoveY(playerOriginPosY, 0.12f).SetEase(Ease.InQuart)) .Append(DOTweenModulePhysics.DOJump(playerRB, PathNode[(script.CurrentNode) + 2].transform.position, 6f, 1, 0.50f, false) .OnStart(() => { script.isGrounded = false; script.trapCollided = true; script.CheckNode(); }) .OnComplete(() => { script.CurrentNode += 2; script.isGrounded = true; script.trapCollided = false; script.CheckNode(); })) .OnStart(() => { }) .OnUpdate(() => { jumperFlag = true; }) .OnComplete(() => { jumperFlag = false; pathFollower.GetComponent <PathFollower>().enabled = true; }) ; } } //} }
// Update is called once per frame void Update() { player_animController.SetTrigger("Idle 1"); DrawLine(); Timer += Time.deltaTime * MoveSpeed; if (Vector3.Distance(Player.transform.position, CurrentPositonHolder) > 1f) { if (Input.touchCount > 0) { Touch touch = Input.touches[0]; if (touch.phase == TouchPhase.Began) { //g.transform.position = Vector3.Lerp(g.transform.position, CurrentPositonHolder, Timer); //g.transform.position = CurrentPositonHolder; playerRagdoll.SetActiveRagdollPhysics(false); var dir = PathNode[CurrentNode].transform.position - Player.transform.position; //a vector pointing from pointA to pointB var rot = Quaternion.LookRotation(new Vector3(dir.x, 0, dir.z), Vector3.up); //calc a rotation that //if (g.transform.position.y == 0f) //if (g.transform.position.y == PathNode[tempNode].transform.position.y)// check if player has landed if (isGrounded && trap_Script.isCollided == false) { //player_animController.SetTrigger("Jump"); Player.transform.DORotateQuaternion(rot, 0.5f); isGrounded = false; DOTweenModulePhysics.DOJump(playerRB, CurrentPositonHolder, 2f, 1, 0.25f, false) //.SetEase(anim_ease) .OnStart(() => { trapCollided = true; }) .OnComplete(() => { isGrounded = true; trapCollided = false; CheckNode(); Player.transform.DORotateQuaternion(rot, 0.5f); }); //DOTweenModulePhysics.DOLookAt(playerRB,CurrentPositonHolder,0.25f,AxisConstraint.None,Vector3.zero); } } } } else { if (CurrentNode < PathNode.Length - 1) { CurrentNode++; CheckNode(); tempNode = CurrentNode; if (CurrentNode == PathNode.Length - 1) { SceneManager.LoadScene("level__2", LoadSceneMode.Single); /* DOTweenModulePhysics.DOJump(playerRB, PathNode[0].transform.position, 1.5f, 1, 0.315f, false).OnStart(() => { isGrounded = false; }).OnComplete(() => { isGrounded = true; }); * CurrentNode = 0; * CurrentPositonHolder = PathNode[CurrentNode].transform.position; * //CurrentNode -= 2;*/ } } } Debug.Log("Grounded:" + isGrounded); }