Raycast ignore list hits acting weird

Here’s the raycast before I add the truck to the ignore list(works fine): https://gyazo.com/4058f59edb55ed0e47166b12e40ee580

However, when I add the truck to the ignore list, things get a little weird(when I shoot at the truck specifically)…

How come when the truck is in the ignore list and when I shoot at it, the rays for the bullets trail off in different directions. I want to the bullet to go through the truck where you clicked when it’s in the ignore list. This is a small test for other issues I’m having with the ignore list.

I’m guessing you’re using Mouse.Hit.p to detect where the gun should aim. Right now, even though your bullets pass through the truck, you character is still aiming at its surface. This gets worse the closer you get to the truck. Make your own raycast to calculate where the gun should aim. Make this raycast ignore the truck.

ScreenPointToRay might be useful. Since ScreenPointToRay returns a ray with length 1, you’ll have to make a new ray with a longer direction.

EDIT: The UnitRay property would probably be more convenient. You still need to create a longer ray of of this ray.

1 Like

I would say ScreenPointToRay with UserInputService is the way to go. You can get the same result with hardly more work, and it seems like the mouse object or most of its components are going to become deprecated in favor of UserInputService.

I don’t remember which staff member I saw address this possibility, but it makes sense seeing as everything related to input is being moved to UserInputService.

Edit: Found it.

1 Like