I’ve been trying to work on this issue for a while now, and this is about the closest I’ve come but it’s still not right yet.
I’ve instantiated an arrow, normalized it because the arrows were way off target. However, even after normalizing the target vector it still seems noticeably off… Also, when I factor in deltaTime into the velocity it slows my velocity down to almost a halt no matter how high I set the projectileSpeed.
Can anyone help me with figuring out how to make the arrow move/land more accurately at a proper speed using deltaTime?
(I’ve tinkered with MovePosition, MoveTowards, etc…and this seems like I have the best outcome so far with using velocity).
Thanks in advance…
void Target(Vector2 target){
Debug.Log(target);
GameObject arrow = Instantiate(projectilePrefab, transform.position, Quaternion.identity);
target.Normalize();
Debug.Log(target);
arrow.GetComponent<Rigidbody2D>().velocity = target * (projectileSpeed * Time.deltaTime);
Destroy(arrow, 3.0f);
}