Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there any real difference between using mouse.Origin and mouse.Hit.p?

Asked by 10 years ago

I've looked through the ROBLOX wiki and forums and found nothing different about them but using CFrame values.

1 answer

Log in to vote
2
Answered by
jobro13 980 Moderation Voter
10 years ago

There is a difference.

First let me point out that mouse.hit is a property of mouse. This is a CFrame. The .p property of a CFrame is the position of that CFrame. In other words you are getting the position of the hit CFrame by mouse.hit.p. Origin and hit BOTH return a CFrame!

The difference is that the origin is "where the mouse came from" (its origin) and the hit is the position where the mouse - uh, well - hits.

So what is this origin then? Where does the mouse start..?

Here is the answer;

local mouse = game.Players.LocalPlayer:GetMouse()
local h = mouse.hit.p
local o = mouse.Origin.p
local pos = game.Workspace.CurrentCamera.CoordinateFrame.p
print(o, pos) --> Notice that they are (almost?) equal! 
print(h)

Thus the origin is the same as Camera.CoordinateFrame :) (run above in a LocalScript)

0
Thanks! This helped +1 CMVProduction 25 — 10y
Ad

Answer this question