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

How would I detect if a character is in a 90 degree angle in front of a part?

Asked by 5 years ago
Edited 5 years ago

How would I have something fire when a part is in the region of 90 degree angle in front of a part? I think I have to do something with math.rad, math.deg, magnitude, and Region3. Here is a (fairly messy) picture of describing what i want to happen:

https://gyazo.com/f0182173181dcda7c2c22b95c89045eb

Here is what im doing right now (although im sure it is completely wrong)

local Distance = 50
local Equation = math.rad(50 / 90)
local playerDistance = plr.Character.HumanoidRootPart.Position
 if (playerDistance - script.Parent.HumanoidRootPart.Position).magnitude <= Equation then
    --do stuff
else
    --do more stuff
end

0
I'd probably just have a cylinder/sphere with .Touched event listening if it's the Player's Character that comes to exist in proximity over time. Pejorem 164 — 5y
0
If it's the area that comes to exist at a point in time then I'd probably Region3 at that time and then use the distance (radius) from the centre of the Region to determine true existence. Pejorem 164 — 5y
0
Get the script to run a checkup on the HumanoidRootPart's orientation of the player, then just proceed. rdkv 12 — 5y
0
How would I do that? Pumpk1n52 22 — 5y

Answer this question