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 » Scripting Helpers
Home Search
 

Re: I don't understand?

Previous Thread :: Next Thread 
Sharpshooter26 is not online. Sharpshooter26
Joined: 26 May 2010
Total Posts: 5166
16 Jan 2013 09:57 PM
Ok well I am recreating a crossbow and I am refrencing a FM one to find out what I need to do and this is the firing function which is later called when the mouse is hit.



function fire(v)


local vCharacter = Tool.Parent

local vPlayer = game.Players:playerFromCharacter(vCharacter)
Tool.Parent.Torso["Right Shoulder"].DesiredAngle = 3 --moves your arm as if firing.

local missile = Tool.Bolt:Clone()

-- find firing direction

local v1 = -Tool.Bolt.CFrame.lookVector.unit
local v2 = v.unit


local dot = (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z)
local ang = math.acos(dot)

-- test if in cone
if (ang < 3.14 / 8) then

else
end

Please explain to me what all this is doing? (I know it is finding the fire direction)
I don't understand the local dot = ? and I have never dealt with math.acos
Report Abuse
Sharpshooter26 is not online. Sharpshooter26
Joined: 26 May 2010
Total Posts: 5166
16 Jan 2013 10:38 PM
Bump
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
16 Jan 2013 11:03 PM
math.acos is the arc-cosine function.
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
16 Jan 2013 11:04 PM
So as that would imply it is essentially solving a triangle.
Report Abuse
eugenevorld is not online. eugenevorld
Joined: 15 Nov 2008
Total Posts: 310
17 Jan 2013 04:35 AM
I'm not sure what dot is myself but acos or cos-1 also known as arccosine, is used in solving an angle, the angle is then later uses it in an expression, it checks whether if the angle is smaller than 3.14, in other words mathematical pi. Pi is also 180 degrees in radians, another form of unit to measure angles. I would assume that it is checking if the angle is smaller than 22.5 degrees,(pi/8 = 180/8 = 22.5). Though I'm not sure why it checks if it is smaller than that degree though as I am not too sure what dot does at the moment.
Report Abuse
eugenevorld is not online. eugenevorld
Joined: 15 Nov 2008
Total Posts: 310
17 Jan 2013 07:11 AM
Oh I found out, dot, or dot product, used in this equation, just finds out the cosine of the angle that is between the two parts, just some complicated stuff. It can also calculate other things but if you'd like to find out more search on google or go onto wikipedia and find Dot Product.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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