Like in the Unturned II devblog#1.
Woah, we have a Gamedev section? I’m posting here now. Anyways it depends a bit on whether you are using raycasting or actual objects. The way I’ve always done it is to add a bit of randomness to the direction of the shot, and have the maximum random area it can shoot increase the longer you hold the trigger down.
This is also how I do it, but I don’t usually have it increase. I am not a fan of that much bloom.
Here is my idea (raycast method):
- get player aim direction (it will probably be in a vector, just convert ti to rotator)
- make a new rotator with random small values on each axis
- add it to player aim direction to get the bullet direction
- convert the bullet direction to vector
- multiply the vector by the range of your gun
- raycast to that multiplied vector location
- get hit result
- do whatever you need to do with it
Best way to do bullets? plz experts