I had a few requests to update my Gravity script, here you are.
Note: If you think the gravity pull is not quite right adjust the sb_gravmul cvar and post your results and the map name. The orbit entity does not send you into an orbit, it only creates a gravitational pull (Just a name guys...) Thanks snake for the help on sb3 support. Make sure your sb3 svn is updated or sb3 support will NOT work.
[media]http://www.youtube.com/watch?v=mKUowpIrOl0[/media]
Cvars
[list]
[*]sb_gravmul - adjusts the gravity
[*]sb_admingeonly - orbit entity admin only
[*]sb_disablegrav - disable gravity around the orbit entity
[*]sb_updatera - Time for each update
[*]sb_rad - radius that gravity extends
[*]sb_affectnoclip - affect players in noclip
[/list]
v1.2 (Quick edit)
[list]
[*]Added logic_case scan, for space build maps in non-space build game modes
[/list]
Change log 0.4 -> 1.1
[list]
[*]Decreased overall lag generated
[*]Recoded gravity, enhances how it responds to the distance
[*]Added propprotection check for the sent (owner, friends, owned can only be affected (admin blocking based on what your PP settings are))
[*]Cleaned up code, combined functions together, localized variables
[*]Decreased rate of update
[*]Decreased pull of gravity, to compensate for the new distance decay.
[*]Fixed SB3 support (Thanks snake ;) )
[*]Fixed bugs with other environments (climate regulators)
[*]Added actual sb planet gravity to equation
[*]Added cvar for sent "adminge only" (sb_admingeonly 0 = Everyone; 1 = Admin only; Default: 0)
[*]Fixed orbit sent affecting itself.[/list]
[url=http://www.garrysmod.org/downloads/?a=view&id=65402][img]http://www.garrysmod.org/img/?t=dll&id=65402[/img][/url]
[url=http://www.garrysmod.org/downloads/?a=view&id=64330][img]http://www.garrysmod.org/img/?t=dll&id=64330[/img][/url]
I really liked that mod!
Thanks
Its fu**ing amazing :D
A whole new level of realism in spacebuild. :) I might have to go try this. By the way... What song was that? ^_^
Awesome! Thanks Echo. =]
@Kidd: No problem man xD
@otoris: The Red - Chevelle (It came by on my pandora radio station and I thought it would sound good on it :) )
Can we have an option to turn this on without being in SB?
can you also make this work on planets with out haveing to spawn this or maby making it a comand
Added, check the new copy ;)
[QUOTE=echo1001;14354863]Added, check the new copy ;)[/QUOTE]
Sweet. Thankies.
Is there anyway to calculate angle and velocity for launching something into a stable orbit?
I spawned 2 sents close to each other, froze them, then spawned an object that moves freely about. It gets pulled to the center point of the two frozen Sents. Is this the desired function of the sents? Because the way I understand planetary gravity, it isn't the way it's supposed to work.
The middle point between two equally heavy objects is one of the LaGrange points (if my memory serves) and objects tend to drift AWAY from it, not TOWARDS it. :D
Don't take this as a complaint, just an observation. :)
Anyways, I guess current way is much easier to achieve orbits than the realistic way and I'm having fun with this nonetheless. :D
EDIT:
[QUOTE=Armandur;14366971]Is there anyway to calculate angle and velocity for launching something into a stable orbit?[/QUOTE]
Since the SENT doesn't seem to be using natural laws of gravity, you'll pretty much have to create your own formula for calculating orbits. :)
Technically the formula for calculating orbital velocity is the square root of (Gravity Constant*Mass of body)/Radius of orbit. However as tuusita added the gravity isn't calculated in this fashion within the code itself. You'd have to come up with your own constant for Gravity * Mass based on the existing numbers.
That's pretty much what i did (except the gravity = gravity of planet or sent multiplier value) But its so easy you can just throw a prop and it will start its own orbit :P
I remember a terribly laggy version of this coming with spacebox. Does this run any better?
By a long shot, I wouldn't say it's completely lagg-less but it can unnoticeable. It runs in my server all the time, it only gets laggy if there are a lot of props. ( +100 )
This seems to have code to run through every single entity.. that's why it'll lag with more and more props.
Why not use a large physicsobject and use the touch hooks of the entity instead? Just put these in the initialize:
self:SetTrigger( true )
self:SetNotSolid( true )
I've never needed this next part, but just in case:
function ENT:PassesTriggerFilters(ent)
return true
end
Those in the entity will make it not actually touchable, but it will still register the touches. That way you can just affect the entities within the physics object. Not have to loop through every single one all the time. Note though, that since physicsobjects can only be premade or cubic(on the fly) you might also want to include some distance calculations to only affect those within a radius. Should still be an optimal solution though.
[QUOTE=ZeikJT;14382655]This seems to have code to run through every single entity.. that's why it'll lag with more and more props.
Why not use a large physicsobject and use the touch hooks of the entity instead? Just put these in the initialize:
self:SetTrigger( true )
self:SetNotSolid( true )
I've never needed this next part, but just in case:
function ENT:PassesTriggerFilters(ent)
return true
end
Those in the entity will make it not actually touchable, but it will still register the touches. That way you can just affect the entities within the physics object. Not have to loop through every single one all the time. Note though, that since physicsobjects can only be premade or cubic(on the fly) you might also want to include some distance calculations to only affect those within a radius. Should still be an optimal solution though.[/QUOTE]
Hmm, if the 'area' of gravity is a physicsobject, does that have any negative effects on players that are inside the 'area', like not being able to use physgun, etc?
[QUOTE=ZeikJT;14382655]This seems to have code to run through every single entity.. that's why it'll lag with more and more props.
Why not use a large physicsobject and use the touch hooks of the entity instead? Just put these in the initialize:
self:SetTrigger( true )
self:SetNotSolid( true )
I've never needed this next part, but just in case:
function ENT:PassesTriggerFilters(ent)
return true
end
Those in the entity will make it not actually touchable, but it will still register the touches. That way you can just affect the entities within the physics object. Not have to loop through every single one all the time. Note though, that since physicsobjects can only be premade or cubic(on the fly) you might also want to include some distance calculations to only affect those within a radius. Should still be an optimal solution though.[/QUOTE]
Hmm, thing is, the environments can not be accessed directly from the space build game mode. The only way is to use a function in spacebuild to detect what environment the entity is near.
[QUOTE=tuusita;14386153]Hmm, if the 'area' of gravity is a physicsobject, does that have any negative effects on players that are inside the 'area', like not being able to use physgun, etc?[/QUOTE]
No, it's not solid, the physgun goes right through it like it's not there.
[QUOTE=echo1001;14457288]Hmm, thing is, the environments can not be accessed directly from the space build game mode. The only way is to use a function in spacebuild to detect what environment the entity is near.[/QUOTE]
Oh bummer. Sounds like someone needs to expose some nice functionality. It would/should lag less if you use a method that doesn't need to loop through every entity. The distance formula is also pretty darned intensive over so many iterations.
Well, It's not like it hits every entity. It checks if the entity has physics, it is unfrozen, and if the physics are awake (the entity has been moving). That leaves out a lot of entities. I've been trying to research faster methods of iterating the gravity force but many of the methods lagg. :/
This would be cool if a map was made useing somthing like this in each planet, will u ever try to add them in to a map? or will u keep them as a tool?
Just beautifle.
[QUOTE=tuusita;14370098]I spawned 2 sents close to each other, froze them, then spawned an object that moves freely about. It gets pulled to the center point of the two frozen Sents. Is this the desired function of the sents? Because the way I understand planetary gravity, it isn't the way it's supposed to work.
The middle point between two equally heavy objects is one of the LaGrange points (if my memory serves) and objects tend to drift AWAY from it, not TOWARDS it. :D
Don't take this as a complaint, just an observation. :)
Anyways, I guess current way is much easier to achieve orbits than the realistic way and I'm having fun with this nonetheless. :D
EDIT:
Since the SENT doesn't seem to be using natural laws of gravity, you'll pretty much have to create your own formula for calculating orbits. :)[/QUOTE]
Well since neither of the two entities has a greater mass than the other it would be kinda semi-realistic that it could get affected by both in that way.
[QUOTE=bobsack;14707602]This would be cool if a map was made useing somthing like this in each planet, will u ever try to add them in to a map? or will u keep them as a tool?[/QUOTE]
I think it is automatically applied to spacebuild maps. At least the one I've tried after getting this addon has gravity near the planets.
[QUOTE=davik91;14723317]Well since neither of the two entities has a greater mass than the other it would be kinda semi-realistic that it could get affected by both in that way.[/QUOTE]
Well, semi-realistic indeed. Now the moving object is pulled towards the middle point, no matter wether or not it is closer to one or the other 'gravity object'. As far as I understand it, the 'realistic way' would be that the object is pulled towards the both 'gravity objects' and it is pulled more strongly towards the one that is closer, not the other way around. ;)
Though, as long as the gravity areas don't overlap it doesn't matter. So, no biggie. :)
Having issues with downloading the file, it gives an error as if the file doesn't exist, can someone upload to a diff mirror?
Someone make a slingshot with this (thing used to fling stuff from planet to planet via orbital rotation force)
[QUOTE=Ecarus;14748164]Having issues with downloading the file, it gives an error as if the file doesn't exist, can someone upload to a diff mirror?[/QUOTE]
Are you still having issues accessing it? Try [url]http://ungamers.com/gravity1.2.zip[/url] if you are
This doesn't work for me in single player for detecting logic_cases. I've tried gooniverse, new worlds, voyages, etc, and it wouldn't work. Spawning the sent manually however did work except when I changed the radius it stopped pulling me completely. Gravity wasn't disabled either.. I'm putting it on my server tomorrow but maybe before then someone could shed some light.. Did it break last update or is it only not working in single player?
Sorry, you need to Log In to post a reply to this thread.