|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 19 May 2014 02:32 PM |
| Bump - any good scripters willing to help? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|