generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: I know nothing about rays and cframe

Previous Thread :: Next Thread 
27StarGhost is not online. 27StarGhost
Joined: 23 Feb 2014
Total Posts: 236
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 is not online. 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
ScripterJohn13 is not online. ScripterJohn13
Joined: 01 Jan 2010
Total Posts: 5658
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image