Help with ball control please

Updated on April 1, 2020 in General
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on April 1, 2020

Hi Guys,
Hope you are well and safe,
well i was trying to have this same ball movement but i did not get any luck (please watch the video).
What i want is the same ball movement 
[MEDIA=youtube]8B3GQcgxVZc[/MEDIA]
Here is my ball movement script :

[SerializeField]
     private float speed = 5;
  
     private Rigidbody2D rigidbody2d;
     public float jumpForce = 2;
  
     private void Awake()
     {
         rigidbody2d = GetComponent();
     }
  
     //private void Update()
     //{
     //    if (Input.touchCount > 0)
     //    {
     //        Touch touch = Input.GetTouch(0);
     //        //Touch touch = Input.GetAxis("Horizontal");
     //        if (touch.phase == TouchPhase.Began)
     //        {
     //            if (touch.position.x < Screen.width / 2 && transform.position.x > -1.75f)
     //            {
     //                //transform.position = new Vector2(transform.position.x - 1.75f, transform.position.y);
     //                rigidbody2d.AddForce(Vector2.left * speed);
     //                rigidbody2d.AddForce(Vector2.up * jumpForce);
     //            }
     //            if (touch.position.x > Screen.width / 2 && transform.position.x < 1.75f)
     //            {
     //                // transform.position = new Vector2(transform.position.x + 1.75f, transform.position.y);
     //                rigidbody2d.AddForce(Vector2.left * speed);
     //                rigidbody2d.AddForce(Vector2.up * jumpForce);
     //            }
     //        }
     //    }
     //}

 
I know that i have to control the rigidbody and the movement, please any help.
thank you
 

  • Liked by
Reply