#Gun knockback in unity 2d (when you shoot it)

1 messages · Page 1 of 1 (latest)

tranquil saffron
#

You mean recoil?

calm furnace
#

Just use AddForce
Easy

calm furnace
#

Opposite of the direction the player is shooting in?

#

It would help to see what sort of recoil youre going for and what your game looks like

#

2d recoil can mean quite a few things

tranquil saffron
#

Multiply the direction vector by -1

#

How are you currently shooting?

brave sapphire
#

but that's a 3d game...

tranquil saffron
#

ah got it

#

but

#

I meant to ask, like how are you shooting them in code

#

like are you raycasting in direction of player look and instantly damaging the hit.point

#

or are you instantiating a projectile in player lookng direction and projectile is travelling

tranquil saffron
#

oh well then

#

you have some kind of direction vector in code?

#

which tells you where to shoot exactly?

#

can I see the code?

#

well there's only one solution then

#

open unity

#

ah, so then, make a vector3 direction = transform.position - mousePosition