# Instantiate bullet toward object

Hi, I’m currently working on a dog fighting game and I would like that when the bullet hits the shield, it ricochet and flies towards the player with increased. It is a 2 person game so whenever the bullet of one player hits the shield of another, it deletes itself and creates the other player’s bullet.

I currently have it where the bullet collides and makes a 180, however I am unable to get it to go towards the player. Does anyone know how to solve this?

``````//Turns around normally
Instantiate(bulletPrefaby, transform.position, Quaternion.Euler(0,0,180));
bulletPrefaby.GetComponent<Bullet>().damage = damage + increaseDamage;
Destroy(gameObject);

//Instantiates with incorrect angle
float playerPosition = playery.transform.position.z - transform.position.z;
Instantiate(bulletPrefaby, transform.position, Quaternion.Euler(0,0, playerPosition));
bulletPrefaby.GetComponent<Bullet>().damage = damage + increaseDamage;
Destroy(gameObject);
``````

Thank you!

Quaternion.Euler takes ANGLES as the parameters, not a positional offset.

Try using this one instead: Unity - Scripting API: Quaternion.LookRotation

The below is untested & uncompiled, but should give you a good sample:

``````Vector3 offset = playery.transform.position - transform.position;
Quaternion facingPlayerX = Quaternion.LookRotatation(offset,Vector3.up);
Instantiate(bulletPrefaby, transform.position, facingPlayerX);
``````

I did not end up finding a solution but I instead chose to change the rotation after the bullet was created.

``````public bool reflectedBullet = false;

void Start()
{
//If bullet clone is reflected
if(reflectedBullet == true)
{
Vector3 FacePlayer = player1.transform.position - transform.position;
float angle = Mathf.Atan2(FacePlayer.y, FacePlayer.x) * Mathf.Rad2Deg;
Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward);
transform.rotation = Quaternion.Slerp(transform.rotation, q, Time.deltaTime * 1000000);
}
}

private void OnTriggerExit2D(Collider2D collision)
{
if (collision.gameObject.tag == "SheildPlayer2" && player1Bullets == true && playerMissile == false)
{
//Create transform in order to only edit the clone and not prefrab
Transform reflectedBullet = Instantiate(player2BulletPrefab, transform.position, transform.rotation * Quaternion.Euler(0, 0, 180));
reflectedBullet.GetComponent<Bullet>().damage = damage + increaseDamage;
reflectedBullet.GetComponent<Bullet>().reflectedBullet = true;
Destroy(gameObject);
}
}
``````