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 » Scripting Helpers
Home Search
 

Re: Magnitude idea

Previous Thread :: Next Thread 
electricpretzel0 is not online. electricpretzel0
Joined: 30 Sep 2008
Total Posts: 1278
05 Aug 2014 11:28 PM
I'd like to know how I'd go about in having a brick rotate a maximum of 90 degrees as you walk closer or further away from a brick in the center of 100 stud radius. This may sound hard to understand but, imagine this.

A brick a position 0,0,0 in the middle of a 100 stud diameter. A brick that turns a certain amount of degrees as you head from negative position to positive position. When you walk across the entire 100 degrees, it will have rotated 90 degrees in total and cannot rotate anymore that way unless you walk back.

Anyone need clarification?
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
05 Aug 2014 11:30 PM
This is easy to understand.
Report Abuse
2eggnog is not online. 2eggnog
Joined: 08 Nov 2008
Total Posts: 1351
05 Aug 2014 11:33 PM
I understand what you mean, and I could prepare an explanation. Give me a couple minutes.
Report Abuse
TeddyBauer is not online. TeddyBauer
Joined: 24 Jul 2014
Total Posts: 224
05 Aug 2014 11:36 PM
No this is a relatively simple idea.

First we need something to measure the amount of degrees needed for every stud upon rotation:

local deg=100/90

now we need a function to get the closest player.

function getPlayerInRadius()
local closest
for i,v in pairs(game.Players:GetChildren())do
if v.Character~=nil and v.Character:FindFirstChild"Torso"~=nil and (Part.Position-v.Character.Torso.Position).magnitude<=100 and (closest==nil or Part.Position-v.Character.Torso.Position).magnitude<=Part.Position-closest.Character.Torso.Position).magnitude) then
closest=v
end
end
return closest
end

now we need something to constantly update the rotation:

while wait()do
Part.CFrame=Part.CFrame*CFrame.Angles(0,0,math.rad(deg)*(getPlayerInRadius()~=nil and (Part.Position-getPlayerInRadius().Character.Torso.Position).magnitude or 0))
end
Report Abuse
2eggnog is not online. 2eggnog
Joined: 08 Nov 2008
Total Posts: 1351
05 Aug 2014 11:37 PM
Just so I understand, the rotation of the outer part depends on the distance the character is from the center?
Report Abuse
2eggnog is not online. 2eggnog
Joined: 08 Nov 2008
Total Posts: 1351
05 Aug 2014 11:38 PM
Nevermind, looks like TeddyBauer got it.
Report Abuse
TeddyBauer is not online. TeddyBauer
Joined: 24 Jul 2014
Total Posts: 224
05 Aug 2014 11:39 PM
*Raises hand to the sky, puts other hand on the hip, [waits 10 seconds] [looks at watch] then mothership beams me up*
Report Abuse
electricpretzel0 is not online. electricpretzel0
Joined: 30 Sep 2008
Total Posts: 1278
05 Aug 2014 11:47 PM
Thanks guys :)
Report Abuse
electricpretzel0 is not online. electricpretzel0
Joined: 30 Sep 2008
Total Posts: 1278
05 Aug 2014 11:52 PM
I have a question. How do I just put the value of a brick's CFrame.Angles without setting them higher?

So, not this,

brick.CFrame * CFrame.Angles(0,0,math.rad(30))

but where I just say that the brick's CFrame is the same but it's Angles is math.rad(30), not incremented by that.
Report Abuse
2eggnog is not online. 2eggnog
Joined: 08 Nov 2008
Total Posts: 1351
05 Aug 2014 11:58 PM
brick.CFrame = CFrame.new(brick.CFrame.p) * CFrame.Angles(0,0,math.rad(30))

CFrame.new(brick.CFrame.p) returns a CFrame in the same position, but with no rotation. The second part simply applies the rotation.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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