|
| 03 Apr 2015 07:18 PM |
Rotate(Gui1.Position, Gui2.Position) cos Rotation is only 1... not UDim2 not Vector3 etc etc...
if u dont get it... I want it like CFrame.new(Part1.Position, Part2.Position) but except with 2D Objects...
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 07:10 AM |
b
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 07:19 AM |
| If you want it, you make it. |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 07:21 AM |
dude... thats wat am asking! HOW
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
|
| 04 Apr 2015 07:32 AM |
| look up trigonometry, specifically inverse tangent function, and how to find angles from sides in a right triangle. |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 07:34 AM |
| I didn't see a question in there. |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 07:46 AM |
Mini, k... Thnx
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
|
| 04 Apr 2015 07:48 AM |
hack way (inefficient)
local screenwidth=1000 local screenheight=1000
function rot(u1,u2)
local p1=Instance.new('Part') local p2=Instance.new('Part') p1.CFrame=CFrame.new(u1.Size.X.Scale*screenwidth+u1.Size.X.Offset,0,u1.Size.Y.Scale*screenheight+u1.Size.Y.Offset) p2.CFrame=CFrame.new(u2.Size.X.Scale*screenwidth+u2.Size.X.Offset,0,u2.Size.Y.Scale*screenheight+u2.Size.Y.Offset) p1.CFrame=CFrame.new(p1.Position,p2.Position)
return p1.Rotation.Y
end
|
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 07:51 AM |
using a Part's Rotation for a 2D Object? Clever :D
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 10:00 AM |
Mini, got more Suggestions? I don't really wanna Create Parts and stuff... I Searched up wat u gave me... couldnt find much useful stuff :/ could u plz give me an example?
I tried using the Positions of the 2 and then tried doing different things with them...
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 10:14 AM |
InvTangent(X / Y) = Rotation IIRC |
|
|
| Report Abuse |
|
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
|
| 04 Apr 2015 10:16 AM |
ok,
you have two guis, A and B they make a right triangle,
A |a\ |__\ c___\ |____\ |_____B d You want A to be pointed towards B, we'll call "a" an angle, the rotation it needs to be assigned to face B. c is the vertical side of the rectangle, d is the horizontal side.
c is equal to the B gui's position X value minus the A gui's position X value
d is equal to the A gui's position Y value minus the B gui's position Y value
We need to find a
From trigonometry, we know:
tan(a)=d/c and atan(tan(x))=x in most cases
so a=atan(d/c)
so the A gui's rotation needs to be set to math.atan(d/c)
|
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 10:16 AM |
em... InvTangent... I have the X and Y Ready... but wat exactly do u mean by InvTangent? in Function Form?
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 10:18 AM |
hmmm... sounds kinda complicated :/
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
| |
|
|
| 04 Apr 2015 10:18 AM |
| Inverse Tangent. IIRC, it is atan on Roblox. |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 10:19 AM |
lol Mini XD Jarod, k, so math.atan(Y, X)?
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 10:19 AM |
I mean math.atan(x/y)
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
|
| 04 Apr 2015 10:23 AM |
no
x needs to be the distance between gui1 and gui2's x positions
y needs to be the distance between gui1 and gui2's y positions |
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 10:26 AM |
Mini, local x = x1 - x2 local y = y1 - y2
x1, x2 = gui1.Pos.X, gui2.Pos.X same with y... I use those...
local xy = x - y
o.Rotation = math.atan(xy * 2.777) and tried o.Rotation = math.atan(xy) and many other things...
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
| |
|
|
| 04 Apr 2015 10:31 AM |
I tried that, nothing WOrked :/
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
|
| 04 Apr 2015 10:35 AM |
kap,
also at the end put, rot=math.deg(rot)
|
|
|
| Report Abuse |
|
|
|
| 04 Apr 2015 10:38 AM |
now it's Rotating too much... here's the Output:
750 500 1.5 85.943672180176
here's the Script:
print(x) print(y) print(xy)
o.Rotation = math.deg(xy) print(o.Rotation)
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
jewelycat
|
  |
| Joined: 10 Sep 2008 |
| Total Posts: 17345 |
|
|
| 04 Apr 2015 10:39 AM |
It should be math.atan(y/x), not x/y
g1 = gui1 g2 = gui2 p = the gui you want to rotate
local x = (g1.AbsolutePosition.X-g2.AbsolutePosition.X) local y = (g1.AbsolutePosition.Y-g2.AbsolutePosition.Y)
p.Rotation = math.atan(y/x) * 180 / math.pi |
|
|
| Report Abuse |
|
|