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: How would I make a GUI object spin around a point?

Previous Thread :: Next Thread 
Zylez is not online. Zylez
Joined: 26 Mar 2016
Total Posts: 417
12 Aug 2016 05:33 PM
I know how to do it in CFrame, but what about UDim?
Report Abuse
Zylez is not online. Zylez
Joined: 26 Mar 2016
Total Posts: 417
12 Aug 2016 05:38 PM
b
Report Abuse
Zylez is not online. Zylez
Joined: 26 Mar 2016
Total Posts: 417
12 Aug 2016 05:44 PM
b2
Report Abuse
Objectly is not online. Objectly
Joined: 18 Jul 2016
Total Posts: 210
12 Aug 2016 05:44 PM
UDim2.new works with 2D positioning across a user's screen so it'd only go around a point on a 2d surface. You can do this with a loop that calculates the math of where the GUI should be via having a mathematically created circle. The object will follow along the circle's radius which will be calculated every loop.
Report Abuse
Zylez is not online. Zylez
Joined: 26 Mar 2016
Total Posts: 417
12 Aug 2016 05:49 PM
Yeah, I figured, but I would like to know the math behind it so that I can do this.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
12 Aug 2016 05:51 PM
math.sin and math.cos


Report Abuse
Tuneable is not online. Tuneable
Joined: 16 Feb 2013
Total Posts: 2932
12 Aug 2016 05:54 PM
2 ways to do this

1. Position a frame to the center point, and add the gui object into the frame. Change the gui object's y position to the radius. Set the frame rotation to the desired rotation.

2. Calculate the position

local function getPosition(position, rotation, radius) -- UDim2, degrees
return UDim2.new(position.Offset.X + math.cos(math.rad(rotation)) * radius, position.Offset.Y + math.sin(math.rad(rotation)) * radius)
end
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
12 Aug 2016 05:54 PM

local scale = 1/4
while wait() do
for i = 0,360,12 do
game.StarterGui.ScreenGui.Frame.Position = game.StarterGui.ScreenGui.center.Position + UDim2.new(math.cos(math.rad(i))*scale,0,math.sin(math.rad(i))*scale,0) wait() end end


Formerly xXTheRobotXx, add 13,349 posts
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
12 Aug 2016 05:59 PM
local dot = script.Parent.Dot
local spin = script.Parent.Spin

local angle = 0

while wait() do
angle = angle + 0.1
spin.Position = UDim2.new(0,dot.AbsolutePosition.X-spin.AbsoluteSize.X/2+math.cos(angle)*60,0,dot.AbsolutePosition.Y-spin.AbsoluteSize.Y/2+math.sin(angle)*60)
end


Report Abuse
Xsitsu is not online. Xsitsu
Joined: 28 Jul 2009
Total Posts: 2921
12 Aug 2016 06:01 PM
You could make a single 1x1 pixel frame that contains the frame you want to spin around something. Position the frame inside of the 1x1 pixel frame to have its corner be in the 1x1 pixel. Then just spin the 1x1 pixel frame and it should work.
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