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

How to offset a ray emitted from Player's HumanoidRP to the left from the Player, not global XYZ?

Asked by 4 years ago
Edited 4 years ago

I'm a rookie with scripting, so not that well-versed.

It only works with global directions opposite of the +/- sign, offsets to the left just fine.

However, if I face the same direction as the +/- sign, it just offsets the ray to the RIGHT.

My goal is to offset the ray's origin (not direction) from the HRP at most 2 studs to the left of my player, and have that offset be reliant on the player's orientation to itself, and not on the global XYZ coordinates.

TL;DR - I just want to change the ray's origin to always be on my left, even in shiftlock.

Sorry if I explained it poorly, I'll give you more information if you need it.

local MixedOriginZ1 = Vector3.new(origin.X origin.Y,origin.Z+1.6)
        local MixedOriginZ2 = Vector3.new(origin.X, origin.Y,origin.Z+0.5)
        local MixedOriginZ3 =Vector3.new(origin.X, origin.Y,origin.Z-0.5)
        --local origin2 = c['Right Arm'].Position
        --local direction2 = c['Right Arm'].CFrame.lookVector*3.5

        --local origin3 = (origin+origin2)/2

        local R = Ray.new(MixedOriginZ2, direction)
        local R2 = Ray.new(MixedOriginZ2,direction2)
        local R3 = Ray.new(MixedOriginZ2,direction3)

The relevant snippet of a much larger script.

0
Not a math solution, but you could just have an invisible part welded to the HRP on the left side of the player where you want the ray to start. SteamG00B 1633 — 4y
0
True, that does solve the problem, I would give you points if no one comes up with a math solution. sonicvsmaio4 4 — 4y
0
UPDATE: Someone solved this problem with this line of code: local RayOrigin = (HRP.CFrame * CFrame.new(-2,0,0)).p sonicvsmaio4 4 — 4y

Answer this question