Currently I’m trying to cast a ray base on the mouse position. For instance:
I’d like to cast only a small distance of ray with the mouse hit direction, the blue arrow indicates where I want to cast the ray. The only problem right now is how do I get the vector3 position or CFrame of the black arrow? I tried to use Mouse.Hit.LookVector but it gives quirky results.
1 Like
There’s actually a property of the Mouse object called “UnitRay”
Maybe you could use that? It shares all the characteristics of a regular ray object.
game.Players.LocalPlayer:GetMouse().UnitRay
https://developer.roblox.com/en-us/api-reference/property/Mouse/UnitRay
2 Likes
How would I use it to calculate the black point?
if understand your problem correctly, if you are trying to “expand” the unit ray (make it longer) you can do something like this:
local ExpandedRay = UnitRay.Origin + UnitRay.Direction * Length
4 Likes