# Problem involving vectors and shooting at the player

Attention Topic was automatically imported from the old Question2Answer platform.

I’m having a problem with vector math as I want to make enemies shoot on current player position. I’m aware of the required vector difference operation, when I do this:

``````var direction = enemy.position - player.position
``````

the game works like that:

and it shoots perfectly at the player, but it is based on distance, so the closer, the slower

of course, I need it to be distance-independent, so I do the proper vector math afterwards:

``````direction = direction.normalized()
direction *= scale
``````

but it end up shooting next to the player, but not in the precise place, like this:

I’ve tried everything. Nothings makes it go to the right place after normalize the vector.
Can someone help me??

How are you moving your bullets, and what is `scale`? Ideally, you should find the direction vector (normalized) and then move your bullet in that direction at its speed (i.e. `velocity = direction * speed`).

kidscancode | 2018-12-30 02:52

THAT was my problem, I was scaling it by a small number like 10, when I tried it with 200 its direction gone to the right place, I feel stupid thanks anyway!!!

Carlos Pazuzu | 2018-12-30 02:56

Find the direction vector (normalized) and then move your bullet in that direction at its speed (i.e. `velocity = direction * speed`).