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: Anaminus' Model Rotation Script - Edited ( Help Needed )

Previous Thread :: Next Thread 
PRESTIGIOUSaLEGEND is not online. PRESTIGIOUSaLEGEND
Joined: 16 Apr 2011
Total Posts: 1765
19 May 2014 02:16 PM
Can anyone tell me why my object "Moon" will not stay in orbit of my object "Earth"?

The script below is a rotation script for a Model containing the object "Moon" and an object "Orbit" which is the shape of the orbit for "Moon" to go around "Earth".

The object "Earth" is also constantly moving. The "Moon" is rotating in its orbit shape but the orbit shape is not keeping a central position relative to the "Earth"

Help is appreciated. Problem is likely to be in the 2nd block of code.



function calculatedifference(pos)
local newpos = script.Parent.Parent.Moon.CFrame
local xdif = newpos.X - pos.X
local zdif = newpos.Z - pos.Z
local diff = math.sqrt((xdif^2)+(zdif^2))
print(diff*20)
end

function TransformModel(objects, center, new, recurse)
local pos = script.Parent.Parent.Moon.CFrame
for _,object in pairs(objects) do
if object:IsA("Part") then
object.CFrame = new:toWorldSpace(center:toObjectSpace(object.CFrame))
end
end
calculatedifference(pos)
end

while true do
local center = script.Parent.Parent.Parent.Earth.CFrame
TransformModel(
script.Parent.Parent:GetChildren(),
center,
center * CFrame.Angles(0,math.rad(1),0),
true
)
wait(0.05)
end
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
19 May 2014 02:18 PM
Moon will only stay in orbit of earth if earths gravity is strong enough to pull the moons mass.

if Earth.Gravity:CanPull(Moon.Mass) then
Earth:Pull(Moon)
end
Report Abuse
PRESTIGIOUSaLEGEND is not online. PRESTIGIOUSaLEGEND
Joined: 16 Apr 2011
Total Posts: 1765
19 May 2014 02:23 PM
Yes, except i don't need the science behind it. I need the code fix that will rotate the moon around the earth while keeping the earth's center as its orbital center.
Report Abuse
PRESTIGIOUSaLEGEND is not online. PRESTIGIOUSaLEGEND
Joined: 16 Apr 2011
Total Posts: 1765
19 May 2014 02:32 PM
Bump - any good scripters willing to help?
Report Abuse
PRESTIGIOUSaLEGEND is not online. PRESTIGIOUSaLEGEND
Joined: 16 Apr 2011
Total Posts: 1765
19 May 2014 03:08 PM
Bump - If you do not understand what i mean then you can visit this place.

http://www.roblox.com/Scientific-Experiments-place?id=157767524

you will notice that the relative speed of the moon is constantly accelerating because it has gone off course.
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