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: Convert offset to scaled?

Previous Thread :: Next Thread 
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 03:31 PM
I have an offset frame that has scaled size. How can I convert the position to scaled? I'm sending the frame to the mouse' position. The mouse' position is in pixels, sooo yeah.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
14 Apr 2016 03:34 PM
hmm

scale = offset/absolutesize


Report Abuse
ghostleader is not online. ghostleader
Joined: 16 Feb 2008
Total Posts: 1131
14 Apr 2016 03:34 PM
https://forum.roblox.com/Forum/ShowPost.aspx?PostID=186928929
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 03:35 PM
@ghost

That was for offset position and offset size I do believe.


@time

I'll try that, thanks
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 03:41 PM
Time, that's very close! But it's not perfect. I'm kinda looking for the closest I can get.

Current:

tower.Position = (tower.Position/tower.AbsoluteSize)
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
14 Apr 2016 03:44 PM
tower.Position = UDim2.new(tower.Position.X.Offset/tower.AbsoluteSize.X,0,tower.Position.Y.Offset/tower.AbsoluteSize.Y,0)


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
14 Apr 2016 03:45 PM
try absoluteposition then if thats really close


Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 03:46 PM
Alright
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 03:50 PM
Turns out I wasn't setting it to scaled. When I set it to scale, it says like 25.5...

;-;
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 04:56 PM
bump
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 05:07 PM
bumpity bump
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 05:18 PM
I pretty much need to implement this as my next feature to my game..
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 05:24 PM
I'm moving the tower to my mouse' location. And the mouse location is in pixels.. Not scaled.. Any other way to do what I'm trying to achieve?
Report Abuse
benthanh123 is not online. benthanh123
Joined: 27 May 2010
Total Posts: 567
14 Apr 2016 05:27 PM
UDim2.new(offset.x/cam.ViewportSize.X,0,offset.y/cam.ViewportSize.Y,0)
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 05:30 PM
Thanks. I think we're getting closer, but this is happening..
https://gyazo.com/202faf50d90be46e7114ef4ce481e9b5
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 05:32 PM
oops i never assigned that UDim2 to the tower's position. lol

trying it now
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 05:34 PM
:D

It works great! Thanks!

Just curious if there's a workaround for this small bug. After I placed my tower, it shifted upward slightly. If there isn't an available workaround, I'll have to shift it downward or something after placement? idk to be honest
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 05:37 PM
Got it! Just had to do some adjusting on the Y axis. Thanks all for your help!!
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 05:49 PM
Cri

This isn't gonna work.. I added like a + .036 to the Y axis and it's working inaccurately. Like for different screen sizes it won't work how it is in studio. Anyone have any other suggestions?
Report Abuse
benthanh123 is not online. benthanh123
Joined: 27 May 2010
Total Posts: 567
14 Apr 2016 05:56 PM
Do it for the size too.
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 06:22 PM
I did, and this time it was very tiny. :l

I changed Position to Size though
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 06:49 PM
last bump for tonight
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 07:22 PM
Ok I lied :c

Bump..
Report Abuse
benthanh123 is not online. benthanh123
Joined: 27 May 2010
Total Posts: 567
14 Apr 2016 07:31 PM
post the script
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Apr 2016 07:36 PM
local function SpawnTower(tower)
mDown = false
tower.Parent = map
tower.Visible = true
while wait() do --This is to move the tower to the mouse' position for placement
tower.Position = UDim2.new(0,m.X,0,m.Y)
if mDown and not CheckCollision(tower) then
break
end
end
tower.RangeCircle.ImageTransparency = 1
tower.Attack.Disabled = false
local cam = game.Workspace.CurrentCamera --Convert from pixels to scaled
tower.Position = UDim2.new(tower.Position.X.Offset/cam.ViewportSize.X,0,(tower.Position.Y.Offset/cam.ViewportSize.Y) + .036,0)
buying = false
end
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