I have a 2d game where player can shoot bullets in a direction of their mouse. Everything works quite fine, but the problem is with bullet spawning. I am creating them on position where player, which is in center of player prefab. That means the bullet appears in a middle of player and then continues in a direction, which is almost what I want.
I would prefer if the bullet was spawned on edge of a player collision though, however I have no idea how to accomplish that, neither how to calculate this.
I know the position of player (X, Y) and I know a position of a mouse (X, Y). I need to calculate where the edge of player in direction from player to mouse is and spawn a bullet there. How would I do that?
For a beginning I would be fine just to know how to get a point X that is N points in distance from point A in direction from A to B.