I’m using the below code in an attempt to shoot an arrow toward the mouse cursor but the arrow just shoots upwards and to the left. How can I get it to shoot toward my cursor?
public void shootArrow(float scaler) {
Vector2 vectorToTarget = Camera.main.ScreenToWorldPoint(Input.mousePosition) - center.transform.position;
arrow = Instantiate (arrowPrefab, center.transform.position, Quaternion.identity) as GameObject;
arrow.GetComponent<Rigidbody2D>().AddForce(vectorToTarget * shootStrength * scaler, ForceMode2D.Impulse);
}