Issue with 3rd person mouse

This should be a simple fix, I’m most likely over-looking it.

Red is where the gun muzzle position
Blue is the players Mouse Position
Purple is where the ray intercepts <<
Black = walls

Graphic_


I have the ray part of this problem solved! (Thanks CoCo! <3)

I’m trying to detect if the player’s mouse position is the same as the Raycast Result’s position.
In scripting terms “if rayposition == mousehit then”

I’m confused as to why you’d want to do this, but could you not just use the RaycastResult value position and check vs the mouses CFrame? I feel like the bullet hit would always be the blue part though unless intercepted since you’re literally just using the mouse data to cast the ray, so arguably you could just do ray.Instance == target

I’m trying to do this to get where the bullet is actually going to land. I think I might’ve worded this poorly, didn’t sleep well.

See where the player is trying to shoot?
The white is where the ray is actually going to hit!

I need a method to detect if the bullet isn’t going to land there, then for this UI to show them where it’s actually going to hit.


I currently have a hacky solution which is subtracting the rayposition and the mousehit position and asking if it’s distance is less than 1, but it’s not always correct.

You can just match RaycastResults.Position against the mouses Position, and if they’re not the same then just return RaycastResults.Position. I assume that you’re doing this on the client as otherwise you’d have input delay, so if you’re doing it on the server it’d be a little less successful.

I have that, but it’s not returning correct all of the time.

An example would be:

As you can see that my mouse is in the center of the screen.


image

In this one you can clearly see that it’s not correct as the bullet holes are far a-part from where it’s detecting.

You’ll have to check if the raycast actually hits anything, but for the bullet hole not being created where the bullets supposed to be, that’ll just be an issue with the actual creation of the image and it’s positioning.

I can ensure you that it’s the detection, the mouse position is correct as I used a 4 second timer before taking the screenshot to ensure the mouse position was never changed
image

Something must be going wrong with the casting of your ray then.

That’s most likely the issue!

On a side note;
Do you know any other posts about this detection, couldnt find any myself?

As in using rays for hit detection? There’s a nice page on the roblox dev help page here, but you can read more about rays on youtube, experimenting, etc.

I was talking about people trying to do the same thing as I am. As in: Detecting the true bullet location

The true bullet location is just the players mouse position

Do you see how I’m trying to shoot the wall, but the wooden post is in-front of me?! The bullet hole is where the ray actually hit.

I need a solution to get real time data on where the bullet is actually going to land, this is the best example I could provid, and I have no other idea on how to explain it

I have no idea how this has to do with the question I asked.