# I am trying to make a ball bounce off a "paddle" but it just gets stuck on it and keeps on getting stuck on the paddle and stays there

Here are the script of the paddle and script

``````using System.Collections;
using System.Collections.Generic;
using UnityEngine;

{
public float speed = 0.06f;
public float xBounds = 2.15f;

int direction = 0;
float previousPositionX;

private GameObject ball;
private float speedBall;

void Start()
{

ball = GameObject.Find("Ball");
}

void Update()
{
Movement();
}

void LateUpdate()
{
previousPositionX = transform.position.x;
}

void Movement()
{
float h = Input.GetAxisRaw("Horizontal");

if(h > 0)
{
transform.position = new Vector2(transform.position.x + speed,
transform.position.y);
}
else if (h < 0)
{
transform.position = new Vector2(transform.position.x - speed,
transform.position.y);
}

if (previousPositionX > transform.position.x)
direction = -1;
else if (previousPositionX < transform.position.x)
direction = 1;
else
direction = 0;

transform.position = new Vector2(Mathf.Clamp(transform.position.x,
-xBounds, xBounds), transform.position.y);
}

void  OnCollisionEnter2D(Collision2D target)
{
float adjust = 3 * direction;
target.rigidbody.velocity = new Vector2(target.rigidbody.velocity.x + adjust,
transform.position.y);
}

}
``````

here is the ball script:

``````using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BallScript : MonoBehaviour
{
public float speed, multiplier, constantSpeed;

public Transform startPoint;
private Rigidbody2D myBody;

private bool canMove, shoot;

void Awake()
{
myBody = GetComponent<Rigidbody2D>();
}

void Update()
{
if (canMove)
{
if (!shoot)
{
shoot = true;
}
}
else
{
transform.position = startPoint.position;
}

if (Input.GetKeyDown(KeyCode.Space))
canMove = true;

myBody.velocity = constantSpeed * myBody.velocity.normalized;
}
}
``````

I really dont know what to do.

Take a look at “Physic Material”, property “Bounciness”. It will help to do correct bounce without any single line of code.
Just create a Physic Material with Bounciness = 1, then add it to ball and paddle