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: Rotating a Gui Object based on 2 Arguments

Previous Thread :: Next Thread 
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
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
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 07:10 AM
b

"My Life is going Good... but..."
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
04 Apr 2015 07:19 AM
If you want it, you make it.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 07:21 AM
dude... thats wat am asking! HOW

"My Life is going Good... but..."
Report Abuse
MiniNob is not online. 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
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
04 Apr 2015 07:34 AM
I didn't see a question in there.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 07:46 AM
Mini, k...
Thnx

"My Life is going Good... but..."
Report Abuse
MiniNob is not online. 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
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
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
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
04 Apr 2015 10:14 AM
InvTangent(X / Y) = Rotation
IIRC
Report Abuse
MiniNob is not online. 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
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
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
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 10:18 AM
hmmm... sounds kinda complicated :/

"My Life is going Good... but..."
Report Abuse
MiniNob is not online. MiniNob
Joined: 14 May 2013
Total Posts: 822
04 Apr 2015 10:18 AM
ninja'd by 2 minutes
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
04 Apr 2015 10:18 AM
Inverse Tangent. IIRC, it is atan on Roblox.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 10:19 AM
lol Mini XD
Jarod, k, so math.atan(Y, X)?

"My Life is going Good... but..."
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 10:19 AM
I mean math.atan(x/y)

"My Life is going Good... but..."
Report Abuse
MiniNob is not online. 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
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
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 is not online. MiniNob
Joined: 14 May 2013
Total Posts: 822
04 Apr 2015 10:26 AM
xy=x/y
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
04 Apr 2015 10:31 AM
I tried that, nothing WOrked :/

"My Life is going Good... but..."
Report Abuse
MiniNob is not online. 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
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
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 is not online. 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
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