GetActiveCheckPointPosition() public static method

Get position of the last activated checkpoint
public static GetActiveCheckPointPosition ( ) : Vector3
return Vector3
コード例 #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (count == 3)
        {
            SceneManager.LoadScene("GameOver");
        }
        else if (other.gameObject.CompareTag("Player"))
        {
            count++;

            other.transform.position = CheckPoint.GetActiveCheckPointPosition();


            // Application.LoadLevel(Application.loadedLevel);
        }
        else if (other.gameObject.CompareTag("Sleepwalker"))
        {
            SceneManager.LoadScene("GameOver");
            SceneManager.LoadScene("Menu");
        }

        else
        {
            Destroy(other.gameObject);
        }
    }
コード例 #2
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Enemy")
     {
         thisRigidbody.transform.position = CheckPoint.GetActiveCheckPointPosition().result;
     }
 }
コード例 #3
0
    //In the update function it starts off with the Jump and goes into the players health.
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            //Not a hard reset, but a reset none the less.
            body2D.transform.position = CheckPoint.GetActiveCheckPointPosition();
            curHealth = maxHealth;
            maxSpeed  = baseSpeed;
            jumpForce = baseJump;
        }

        if (Input.GetButtonDown("Fire2"))
        {
            maxSpeed  = 4;
            baseJump  = 550;
            jumpForce = 550;
        }
        //Currently Jump is just the space button for testing purposes, we will change this!
        if (grounded && Input.GetButtonDown("Jump"))
        {
            anim.SetBool("Ground", true);
            anim.SetBool("Jumping", true);
            body2D.AddForce(new Vector2(0, jumpForce));
            //Jump Audio
            jumpSource.clip = jumpsound;
            jumpSource.Play();
        }
        else
        {
            anim.SetBool("Ground", false);
        }

        if (!grounded)
        {
            anim.SetBool("Ground", true);
            anim.SetBool("Jumping", true);
        }
        else
        {
            anim.SetBool("Ground", false);
        }
        //Checks whether you have Health.
        if (curHealth > maxHealth)
        {
            curHealth = maxHealth;
        }

        if (curHealth <= 0)
        {
            Die();
        }
    }
コード例 #4
0
    IEnumerator WaitFor()
    {
        maxSpeed  = 0f;
        jumpForce = 0f;
        //play death animation
        //anim.SetBool("Death", true);
        yield return(new WaitForSeconds(2f));

        body2D.transform.position = CheckPoint.GetActiveCheckPointPosition();
        curHealth = maxHealth;
        maxSpeed  = baseSpeed;
        jumpForce = baseForce;
    }
コード例 #5
0
 void Update()
 {
     //resets position to last checkpoint position(BUG: certain checkpoint not registering especially checkpoint3)
     if (Input.GetKeyDown(KeyCode.R))
     {
         Quaternion temp = transform.rotation;
         temp.z = 0;
         temp.x = 0;
         r_Body.transform.position = CheckPoint.GetActiveCheckPointPosition();
         transform.rotation        = temp;
     }
     //when mouse button is held after certain speed lets you boost but at cost of handling increases max speed and torque also plays the boost particles
     if (Input.GetMouseButton(0))
     {
         if (currentSpeed > maxSpeed - 15)
         {
             maxSpeed = 65;
             torque   = 3000;
             boost1.Play();
             boost2.Play();
         }
     }
     //when mouse button is released resets speed to old values and gets rid of boost particle effect
     if (Input.GetMouseButtonUp(0))
     {
         torque   = oldTorque;
         maxSpeed = oldSpeed;
         boost1.Stop();
         boost2.Stop();
     }
     //if accelerating lets you brake, plays the audio for brakes
     if (Input.GetKey(KeyCode.Space))
     {
         for (int i = 0; i < 4; i++)
         {
             wheelcolliders [i].brakeTorque  = 0;
             wheelcolliders [i].motorTorque  = 0;
             wheelcolliders [i].brakeTorque += accelerate * 2000;
         }
         skid.PlayOneShot(audios[2]);
     }
     //when space is let go resets brake torque to
     else
     {
         for (int i = 0; i < 4; i++)
         {
             wheelcolliders[i].brakeTorque = 0;
         }
     }
     SpeedControl();
 }
コード例 #6
0
ファイル: Gamemanager.cs プロジェクト: RENCURELI/LD45
    /// <summary>
    /// React to player death
    /// </summary>
    /// <param name="propType"></param>
    public void onDeathMessage(GameObject propType)
    {
        Debug.Log("PlayerDead");
        Debug.Log("Current State = " + curState);

        //Player position takes active checkpoint position
        GameObject.FindGameObjectWithTag("Player").transform.position = CheckPoint.GetActiveCheckPointPosition();
        //Freeze player rotation
        GameObject.FindGameObjectWithTag("Player").GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;

        //On player input, unfreeze rotations
        if (Input.anyKey)
        {
            GameObject.FindGameObjectWithTag("Player").GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None;
        }
    }
コード例 #7
0
    IEnumerator Death()
    {
        //Death Audio
        deathSource.clip = deathsound;
        deathSource.Play();

        maxSpeed  = 0f;
        jumpForce = 0f;
        //anim.SetBool("Dead", true);
        yield return(new WaitForSeconds(0f)); //2f

        //This needs to be updated in case they run out of lives?
        body2D.transform.position = CheckPoint.GetActiveCheckPointPosition();
        curHealth = maxHealth;
        maxSpeed  = baseSpeed;
        jumpForce = baseJump;
    }
コード例 #8
0
        private void FixedUpdate()
        {
            m_Grounded = false;

            Collider2D[] colliders = Physics2D.OverlapCircleAll(m_GroundCheck.position, k_GroundedRadius, m_WhatIsGround);
            for (int i = 0; i < colliders.Length; i++)
            {
                if (colliders[i].isTrigger)
                {
                    if (colliders[i].tag == "Gravity Normal")
                    {
                        m_Rigidbody2D.gravityScale = 3;

                        if (!m_FacingUp)
                        {
                            FlipVertical();
                        }
                    }
                    else if (colliders[i].tag == "Gravity Reverse")
                    {
                        m_Rigidbody2D.gravityScale = -3;

                        if (m_FacingUp)
                        {
                            FlipVertical();
                        }
                    }
                }

                if (colliders[i].CompareTag("Ground") || (colliders[i].CompareTag("Player") && colliders[i].name != gameObject.name))
                {
                    m_Grounded = true;
                }

                if (colliders[i].CompareTag("Danger"))
                {
                    m_Rigidbody2D.transform.position = new Vector3(CheckPoint.GetActiveCheckPointPosition().x, m_Rigidbody2D.transform.position.y, m_Rigidbody2D.transform.position.z);
                }
            }
            m_Anim.SetBool("Ground", m_Grounded);

            // Set the vertical animation
            m_Anim.SetFloat("vSpeed", m_Rigidbody2D.velocity.y);
        }