Hi my enemies throw axes to hero ım using this code below to do this but when my hero is far direction vector gets bigger and axes move faster ı dont want to do that.How can ı make axes’ speed constant
Rigidbody2D rb;
GameObject hero;
void Awake()
{
rb = GetComponent<Rigidbody2D>();
hero = GameObject.Find("Main_hero");
}
// Update is called once per frame
void Update()
{
}
public void addspeed(GameObject axe)
{
float dx = hero.transform.position.x - transform.position.x;
float dy = hero.transform.position.y - transform.position.y;
Vector2 direction = new Vector2(dx, dy);
rb.velocity = direction * 2;
}