Hello! I’ve been trying to recently work on an old idea of mine, a space simulator which is normally in 0 gravity but has special fields that apply a force to everything in a specific direction, pretty much like the classic conveyor script, but of course using that one is not possible as it does not function when the part cannot collide, and it does kind of generate it’s own movement as well, which would hinder working with spaceships and so on.
I did recently discover a script which does actually work in such a way and would possibly allow me to progress further in creating this game, but it is not perfect and I am here to ask if it’s possible to slightly modify the script, as it’s too complicated for me to really do anything with it.
Here’s the script of the field that I am using to generate gravity.
script.Parent.Touched:Connect(function(hit)
float = Instance.new("BodyVelocity",hit)
float.MaxForce = Vector3.new(0,hit:GetMass()*2,0)
float.Velocity = Vector3.new(0,10,0)
float.Name = "WaterFloat"
if hit.Velocity.Magnitude >= 30 then
splash = script.Parent.Splash:Clone()
splash.Name = "Splash"
splash.Parent = hit
splash.Enabled = true
splash.AutomaticToggle.Disabled = false
if hit.Velocity.Magnitude >= 220 then
hit:BreakJoints()
end
end
end)
script.Parent.TouchEnded:Connect(function(hit)
hit.WaterFloat:Destroy()
end)
The first problem is with a different script I am using which is a gravity controller, if I remember right it does something to the player’s avatar that results in the field not applying velocity to the player, it is problematic as I want the gravity to of course work on the player as well. I will provide the scripts for the gravity controller later when someone requests it, the last time I did provide so many scripts instantly, it scared everyone away. But it’s not the most important problem, I might as well somehow attach a part to the player which the gravity will work on instead (though I did check and it still does not work on items or morphs in any way)
Second problem is that the script applies said velocity world-wise and not field-wise, what does it mean exactly? Pretty much no matter the rotation of the field which applies the gravity, the blocks will always go in the same direction specified in the script, I do not want that to be a thing as the fields will be used onboard of space ships which will change their position and rotation, of course we always want the gravity to point towards the floor. This could be changed in many ways surely, possibly using an other script which would change the vectors specified within the script, depending on the current XYZ orientation of the field, or otherwise somehow changing the script so it will just apply the velocity field-wise instead. There’s always the option that someone has or knows a script or a method which does a better job at what I am trying to achieve here, that would be very fortunate, for instance some wind script or water pull script that would pull blocks and players in a specific direction, and could be repurposed as a gravity system.
I am very thankful for any help!