コード例 #1
0
ファイル: PlayerMovement.cs プロジェクト: finalspace/TryAgain
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Water")
        {
            scoreText.SetActive(false);
            uiFunctions.gameStarted = false;                //Disable the game
            uiFunctions.GameEnded();
        }

        if (collision.gameObject.tag == "CtrlPlatform")
        {
            //myRB.velocity = Vector3.Reflect (myRB.velocity, collision.contacts [0].normal) * 2;
            //myRB.AddForce (myRB.velocity.normalized * 1000);



            Vector3 normal    = collision.contacts[0].normal;
            Vector3 localVel  = vel;            // myRB.velocity;
            Vector3 targetVel = collision.gameObject.GetComponent <PlatformBalance> ().GetVel();
            //Debug.Log (targetVel);

            ///Debug.Log(Vector3.Angle(localVel, normal));
            // measure angle
            if (Vector3.Angle(localVel, normal) < maxAngle)
            {
                // bullet bounces off the surface
                Vector3 newVel = Vector3.Reflect(localVel, normal);
                Debug.Log(Vector3.Dot(targetVel, newVel));
                //myRB.velocity = newVel * (Vector3.Dot (targetVel, newVel));
            }
            else
            {
            }
        }
    }
コード例 #2
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Platform")
     {
         Destroy(Instantiate(hazardDustParticles.gameObject, transform.position, Quaternion.identity), hazardDustParticles.startLifetime);
         this.gameObject.SetActive(false);
     }
     if (collision.gameObject.tag == "Player")
     {
         uiFunctions.gameStarted = false; // Stop the game
         uiFunctions.GameEnded();
         Destroy(Instantiate(hazardDustParticles.gameObject, transform.position, Quaternion.identity), hazardDustParticles.startLifetime);
         this.gameObject.SetActive(false);
     }
 }
コード例 #3
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Platform" || collision.gameObject.tag == "CtrlPlatform")
        {
            Destroy(Instantiate(hazardDustParticles.gameObject, transform.position, Quaternion.identity), hazardDustParticles.startLifetime);
            this.gameObject.SetActive(false);
        }

        if (collision.gameObject.tag == "Player")
        {
            scoreText.SetActive(false);
            //restartButton.SetActive (true);     //Enable the restart button
            //homeButton.SetActive (true);        //Enable the home button
            uiFunctions.gameStarted = false;                //Disable the game
            uiFunctions.GameEnded();
            //SceneManager.LoadScene (SceneManager.GetActiveScene ().buildIndex);
            //Vector3 moveDir = new Vector3 (0, 10, 0);
            //myRB.velocity = moveDir * 50 * Time.fixedDeltaTime;
        }
    }