|
| 05 Oct 2016 11:21 PM |
I gutted the crap out of a free model and modified it in hopes of getting a working model of something that slowly kills you when you look at it. Well there was a lot of terms in the script that i really didnt understand and going to roblox wiki didn't help, since i needed a basic knowledge of cframe(which i dont have that good of a knowledge of cframe). But I stumbled across things like :dot, .unit, FindPartOfRay, and look vector. Does anyone happen to know any of this or have those really handy dandy threads saved that goes into alot of detail explaining this? thanks.
(spoilers, the script didnt work how i wanted it to be.)
|
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 05 Oct 2016 11:25 PM |
LookVector is similar to the rotation of a brick, its where the brick is facing, used mostly w/ torso
|
|
|
| Report Abuse |
|
|
|
| 05 Oct 2016 11:28 PM |
You can use vectors and no cframes for this other than to get components.....
so say:
lookVector = workspace.CurrentCamera.CFrame.lookVector directionVector = (workspace.Part.Position - workspace.CurrentCamera.CFrame.p).unit
--dot product is basically... AB cos(theta) -- since A and B are unit vectors they are both 1 and you get cos(theta) --A and B are magnitudes of your two vectors and theta is angle between them
local dotProduct = lookVector:Dot(directionVector); local angle = math.deg(math.abs(math.acos(dotProduct))); print(angle); if(angle <= 45)then print("Looking within 45 degrees of target!"); end
-- and voila you have it... might have some errors because i just wrote it in here without testing it, but that is the theory you are looking for.. |
|
|
| Report Abuse |
|
|