Data Realms Fan Forums http://45.55.195.193/ |
|
Resisting gravity/GlobalAccel http://45.55.195.193/viewtopic.php?f=73&t=25393 |
Page 1 of 1 |
Author: | Darlos9D [ Fri Sep 02, 2011 12:54 am ] |
Post subject: | Resisting gravity/GlobalAccel |
So obviously one can access the global acceleration (which usually just means gravity) by using the SceneManager property GlobalAcc. Thing is, it doesn't seem to be stored in a "per frame" value. How would I calculate it out to figure out the vector needed to let an object counteract gravity on every frame/update? ... or can I change an object's GlobalAccScalar through lua? |
Author: | Grif [ Fri Sep 02, 2011 1:25 am ] |
Post subject: | Re: Resisting gravity/GlobalAccel |
GlobalAccSalar. It's misspelled. No, really. But the property is modifiable through Lua. |
Author: | TheLastBanana [ Fri Sep 02, 2011 2:24 am ] |
Post subject: | Re: Resisting gravity/GlobalAccel |
Actually, isn't it "GlocalAccScalar"? |
Author: | zalo [ Fri Sep 02, 2011 2:54 am ] |
Post subject: | Re: Resisting gravity/GlobalAccel |
TLB, didn't you do a thing in one of your scenes or something that could create true 0-gravity for an object by giving it a velocity according to the delta time? |
Author: | Azukki [ Fri Sep 02, 2011 3:05 am ] |
Post subject: | Re: Resisting gravity/GlobalAccel |
There was a zero-g bunker system in the mercenaries ballistics weapons mod, and I think it did use deltatime and reference the global accelleration. I don't know if it ever got perfect performance for varying fps levels, though. Here's some discussion on the matter, amidst the drama. viewtopic.php?f=61&t=14783&hilit=gravity&start=120 |
Author: | TheLastBanana [ Fri Sep 02, 2011 3:55 am ] |
Post subject: | Re: Resisting gravity/GlobalAccel |
Zalo, the stuff Azukki linked to may actually have been what you're thinking of, although I honestly can't remember which of the bunkers I made for that mod (and numgun removed the credits, so I guess we'll never know). I can't think of anything else I did for zero-gravity, but I could be wrong. |
Author: | Darlos9D [ Fri Sep 02, 2011 3:30 pm ] |
Post subject: | Re: Resisting gravity/GlobalAccel |
Grif wrote: GlobalAccSalar. It's misspelled. No, really. But the property is modifiable through Lua. Well, I guess I'll just use GlobalAccSailor then. |
Author: | Mehman [ Fri Sep 02, 2011 6:04 pm ] |
Post subject: | Re: Resisting gravity/GlobalAccel |
I don't think GlobalAccScalar can be modified by a script(if it can tell me how), but this can be used to counteract gravity: Code: self.ZeroGVector = Vector(); self.ZeroGVector.Y = SceneMan.GlobalAcc.Y*TimerMan.DeltaTimeSecs; self.ZeroGVector.X = SceneMan.GlobalAcc.X*TimerMan.DeltaTimeSecs; Then just substract self.ZeroGVector from the velocity of the object you want 0 gravity for. |
Author: | Darlos9D [ Fri Sep 02, 2011 7:07 pm ] |
Post subject: | Re: Resisting gravity/GlobalAccel |
That method seems to work, numerically. Something I did in the past was just create an invisible "gravity test" particle that hits nothing when the actor is created, and then just look at its velocity one frame later to get the global accel. It's how I made my flying drone work. That method seems to get a very similar value to what just multiplying by delta time seems to get. Weird thing is, now my actors are STILL sinking down slowly. I really wish globalAcc was applied BEFORE lua gets run, so just setting velocity to zero would effectively pin an actor. Sigh... |
Author: | Mehman [ Fri Sep 02, 2011 7:11 pm ] |
Post subject: | Re: Resisting gravity/GlobalAccel |
Darlos9D wrote: Weird thing is, now my actors are STILL sinking down slowly. That can be solved by giving the actor a very small upwards acceleration, that's what I did for my heavy UAV and it works perfectly. |
Author: | Darlos9D [ Fri Sep 02, 2011 8:16 pm ] |
Post subject: | Re: Resisting gravity/GlobalAccel |
Uhm... what amount would you suggest for that acceleration? |
Author: | Mehman [ Sat Sep 03, 2011 1:36 am ] |
Post subject: | Re: Resisting gravity/GlobalAccel |
After some experiments I fund out that this works perfectly: Code: self.ZeroGVector = Vector(); self.ZeroGVector.Y = SceneMan.GlobalAcc.Y*TimerMan.DeltaTimeSecs; self.ZeroGVector.X = SceneMan.GlobalAcc.X*TimerMan.DeltaTimeSecs; self.Vel = self.Vel - self.ZeroGVector; self.Pos.Y = self.Pos.Y-((SceneMan.GlobalAcc.Y*TimerMan.DeltaTimeSecs)/3); |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |