#gun raycasting shenanigans

1 messages · Page 1 of 1 (latest)

static light
#

I need the gun's bullets to shoot in the direction they're supposed to. they do this when I point towards an object but when I try to fire into the sky they fly towards the screen. also they fly all over the place when I try to shoot the ground through my character
code: https://pastebin.com/jThBRiQw

proud yarrow
#

I have heard that with raycasting if you shoot at the sky it wigs out and or throws a nil condition.. as to if you are panned out of your character and pointing the mouse, it is maybe confused...

#

paste ur code here with and some pics of the issue might help

static light
#

@proud yarrow I already posted the code, that's the pastebin link

proud yarrow
#

yes you did

#

2nd pic, if it is raycasting from what I have read, raycasting at the sky as mentioned wigs out and you have to check for a null /nil conditions or something... (from my limited non coding it)...

#

3rd pic, it looks like it is 'working correct' , in that perhaps from where it starts, perhaps the gun barrel, your mouse is backwards behind it, and it is thus shooting backwards,

#

what I would do, if you want, is add code, to turn the player in the directions of where the mouse is pointing, which in turn will have the gun pointing in the same directions...

#

or add some crazy code to check if the mouse is behind the starting point, then do not fire . or something like tthat

static light
proud yarrow
#

okie dokie

static light
#

if the gun can't be fired while moving then that makes gameplay extremely slow and difficult when it needs to be fast and exciting

#

I imagine it has to be some raycasting filtering issue but I've double-checked and it's filtering out the player as part of the list of things to ignore