# unity bounce without physics

Alright so I’m just completely stuck on how to do this I am using velocity to make my projectile rotate and move forward towards the player which is all working fine what I am stuck with is having a mechanic In my game that the player puts up a barrier to then bounce the projectile of it and give it a new force in direction depending on where it hit this barrier (pong) any help would be super amazing been on this one for few days now.
so this is my basic bullet rotating towards player code since I’m sure my paragraph explained it terribly.

``````private GameObject target;
private Vector3 targetPoint;
private Quaternion targetRotation;
public float speed = 2.0f;
public float MoveSpeed = 30.0f;
void Start ()
{
target = GameObject.FindWithTag("Player");
}

void Update()
{
targetPoint = new Vector3(target.transform.position.x, transform.position.y, target.transform.position.z) - transform.position;
targetRotation = Quaternion.LookRotation (targetPoint, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * speed);
transform.Translate (Vector3.forward * MoveSpeed * Time.deltaTime);
}
``````

}

private GameObject target;
private Vector3 targetPoint;
private Quaternion targetRotation;
public float speed = 2.0f;
public float MoveSpeed = 30.0f;

``````// added a barrier radius x. assumes barrier always x in front of target

void Start()
{
target = GameObject.FindWithTag("Player");
}

void Update()
{
targetPoint = new Vector3(target.transform.position.x, transform.position.y, target.transform.position.z) - transform.position;
targetRotation = Quaternion.LookRotation(targetPoint, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * speed);

// calculate movement for easy access
Vector3 movement = transform.forward * MoveSpeed * Time.deltaTime;

// get distance to barrier
float distanceToBarrier = Vector3.Distance(transform.position, targetPoint) - barrierRadius;

// if movement will encroach barrier radius then...
if (movement.magnitude > distanceToBarrier)
{
// move the projectile to the barrier
transform.position += movement.normalized * distanceToBarrier;

// subtract the distance the projectile travelled to the barrier
movement -= movement.normalized * distanceToBarrier;

// then ricochet
// for this example i will simply reflect the projectile straight back
movement *= -1f;
transform.rotation = Quaternion.Inverse(transform.rotation);

// we can then leave this if clause and finish the movement
}

// move the transform
transform.position += movement;
}
``````