im in a bit of a pickle.
im starting video tutorial series about top down 2d shooter, but im having problem with shooting part.
for moving im using "get axis vector" which i then convert into vector2 and "set velocity 2d".
and then i use this vector2, and using it for shooting.
shooting is done with raycasts. i use raycast 2d, and for direction, i use "vector2".
everything works great and i can shoot when
i am moving. but when i am not moving, vector2 gets set to 0,0. so obviously raycast direction then is 0,0 and that is a problem since it doesnt send raycast to any direction.
so how can i set raycast2d into direction where player was going before he stopped.
i tried setting vector2 variable, into another vector2 variable...
i also tried using vector2 compare, to compare when vector2 is 0,0 and then do something.
but i just cant figure out... im sure there is some simple way that i am not seeing...
basically vector2 has all of these values: 0,1 1,1 1,0 0,0 -1,0 0,-1 -1,1 1,-1 -1,-1
so yes, player can go into 8 directions, plus 0,0 which is standing still. like i said, im having problem with standing still....
lets say player was going into direction 1,0 which is to the right. so vector2 value would be 1,0.
and if player would want to shoot, bullets would go into 1,0 direction. which is to right. but the problem is when player stops, and his vector2 goes to 0,0. but player is still facing right. so if he wants to shoot then, he cant because vector2 is 0,0.
so how can i set vector2 variable back to whatever value it was before it reached value 0,0