|
| 20 Jun 2014 11:05 PM |
| Title says it all. I've already done this before on as3 with 2d trig. How do I do this on roblox? |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:07 PM |
define mouse
block.CFrame = CFrame.new(somecframehere, mouse.Hit.p)
the second argument of cframe is focus |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:07 PM |
Probably just CFrame.
CFrame has a constructor that goes something like this:
CFrame.new(Vector3, Vector3)
The first Vector3 is the position that the part will be placed on, and the second is the position that it will be facing. You can get the 3D 'position' of the mouse with the Hit property of the PlayerMouse
-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::] |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:10 PM |
pos1, pos2 = Vector3.new(0,10,0), Vector3.new(0,0,10) off = (pos2 - pos1) mag = math.sqrt(off.x^2 + off.y^2 + off.z^2) unit = Vector3.new(off.x/mag, off.y/mag, off.z/mag) cf = CFrame.new(pos1) * CFrame.Angle(-math.asin(unit.y),math.atan2(unit.x, -unit.z),0) |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:12 PM |
| Wow, fast reply. Thanks, it works now. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:12 PM |
| use mine, if you show people it you'll look cool :) |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:15 PM |
@AMaster
Where do you learn Ttig for 3D, any sites you specifically recommend, or should I just search? School does not teach me anything that I can apply here. (Still do not know how asin/acos/atan is different from the normal trig) |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:18 PM |
Are you familiar with SOH CAH TOA?
-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::] |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:18 PM |
i would recommend KhanAcademy.org to learn trig. they also have cool programming section with crytography and stuff, but it looks like its made for 4th graders :p
gl on learning trig. if you want add me on skype and i can give you some help with it.
my skype: braden.godley |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:19 PM |
I could make a little post right now that explains asin/acos/atan if you'd like
-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::] |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:20 PM |
Yes swim I am, but not asin/acos/atan and I am not familiar with using with for circles or anything special. I only know triangles.
Amaster: Thanks. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:27 PM |
Searched it up, acos/etc. is inverse. Going to look into it more, and you don't need to swim. Thanks anyway. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:27 PM |
Perfect! Then this will be easy
So as you know, sin(angl) = opposite / hypotenuse. But what if we know what the opposite and the hypotenuse are, but not the angle? Well, then we use asin! So we're going to put asin() around each side of the equation like this:
asin(sin(angl)) = asin(opposite / hypotenuse)
asin is the inverse of sin, so they cancel each other out, so we end up with this equation
angl = asin(opposite / hypotenuse)
And now we've found our angle! YAY MATH!
Does that make sense? Anything that isn't clear?
-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::] |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:27 PM |
@dueling
TOO LATE :D
-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::] |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 11:29 PM |
Thanks for the help. Even though I searched it up :L |
|
|
| Report Abuse |
|
|