Your Cart
Loading
unity 2d ball bounce tutorial unity 2d ball movement tutorial

Unity 2D Ball Bounce Tutorial | Unity 2D Ball Movement Tutorial | Unity Tutorial

Unity 2D Ball Bounce Tutorial | Unity 2D Ball Movement Tutorial | Unity Tutorial


In this video tutorial, you'll learn how to create dynamic ball movement and realistic bouncing effects in Unity 2D. We'll cover essential techniques, including setting up the Rigidbody2D, applying forces, and fine-tuning collisions for smooth gameplay. Perfect for beginners and anyone looking to enhance their Unity skills!



WATCH FULL TUTORIAL ON YOUTUBE



CHECK OUR PROJECTS


SUBSCRIBE FOR LATEST OFFERS



=========================================================


Unity Projects - ON SALE!!!


1. Water Sort Puzzle 9000 Levels

https://payhip.com/b/cjDb8


2. Ball Sort Puzzle 9000 Levels

https://payhip.com/b/IbtoD


3. Sling Shot

https://payhip.com/b/PjLDH



=========================================================



Scripts:


BallController.cs



using UnityEngine;


public class BallController : MonoBehaviour


{


 public float moveSpeed = 5f;


 public float jumpForce = 10f;


 public Transform groundCheck;


 public LayerMask groundLayer;


 public float groundCheckRadius = 0.2f;

  


 private Rigidbody2D rb;


 private Vector2 moveDirection;


 private bool isGrounded;



 private void Start()


 {


  rb = GetComponent<Rigidbody2D>();


 }


 private void Update()


 {


  // Input handling


  float moveX = Input.GetAxis("Horizontal");


  moveDirection = new Vector2(moveX, 0).normalized;


  // Check if player is on the ground


  isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer);


  // Jump input


  if (isGrounded && Input.GetButtonDown("Jump"))


  {


   rb.velocity = new Vector2(rb.velocity.x, jumpForce);


  }


 }



 private void FixedUpdate()


 {


  // Apply movement


  rb.velocity = new Vector2(moveDirection.x * moveSpeed, rb.velocity.y);


 }


}





DOWNLOAD CODESTER FILES