Ejemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (Input.GetMouseButtonDown(0))
        {
            ManagerReferences refs = GameObject.Find("Manager").GetComponent <ManagerReferences>();
            if (refs.gameIsON && body.gravityScale == 0) // graityScale == 0 علشان منعملش فك فريز لجسم فعلا مش فريز
            {
                refs.UnFreezPlayer();
            }



            //add force upward or add impules upward
            if (body != null)
            {
                body.AddForce(Vector2.up * intansity);//push to up
            }
        }
        //limit force
        //Debug.Log("velocity" + body.velocity.y);
        if (body.velocity.y > Maxvelocity)
        {
            body.AddForce(Vector2.down * intansity); ///To reduce the force of the ball when falling down to keep going up
        }
    }