# Getting normal vector of the surface of collision

Discussion in 'Spigot Plugin Development' started by bielsr, Jul 3, 2015.

1. ### bielsr

How can i get the normal vector of the surface of a projectile collision (on the ProjectileHitEvent).
For example if a snowball collides with a block from the top the resulting vector would be (0, 1, 0). From the north face it would be (1, 0, 0) and so on.
I want to use this information to make realistic physics effects, I know how to do the rest but I got stuck here. Any help would be very much appreciated

2. ### sothatsit Patron

Get the arrows location in relation to the block. Simplify it to either 1, 0 or -1. Loop through BlockFace's until you found one that matches your x, y and z.

3. ### bielsr

Thanks @sothatsit , I'll try thar right now. By the way, what do you mean by "simplifying"? Rounding with Math.Round(..)?

4. ### sothatsit Patron

If it's positive, set it to 1, if its negative set it to -1, if its 0, leave it as 0.

Also, that needs to be difference in Block coordinates! Use Math.floor on everything first, before getting the 1, 0 or -1

5. ### MrBlobman

In 3 dimensions you will need another vector to find your normal. You can then take the crosss product of the 2 to get your normal.

6. ### Sunkid

I follow the trajectory of the projectile. You can get the position at any tick. I would not recommend this way as the first posters idea seems reasonable. just throwing my two cents in lol.