View unanswered posts | View active topics It is currently Thu Dec 26, 2024 5:28 pm



Reply to topic  [ 12 posts ] 
 Resisting gravity/GlobalAccel 
Author Message
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post 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?


Fri Sep 02, 2011 12:54 am
Profile YIM
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Resisting gravity/GlobalAccel
GlobalAccSalar. It's misspelled. No, really.

But the property is modifiable through Lua.


Fri Sep 02, 2011 1:25 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Resisting gravity/GlobalAccel
Actually, isn't it "GlocalAccScalar"?


Fri Sep 02, 2011 2:24 am
Profile WWW

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post 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?


Fri Sep 02, 2011 2:54 am
Profile WWW
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post 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


Fri Sep 02, 2011 3:05 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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.


Fri Sep 02, 2011 3:55 am
Profile WWW
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post 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.


Fri Sep 02, 2011 3:30 pm
Profile YIM
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post 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.


Fri Sep 02, 2011 6:04 pm
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post 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...


Fri Sep 02, 2011 7:07 pm
Profile YIM
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post 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.


Fri Sep 02, 2011 7:11 pm
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Re: Resisting gravity/GlobalAccel
Uhm... what amount would you suggest for that acceleration?


Fri Sep 02, 2011 8:16 pm
Profile YIM
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post 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);


Sat Sep 03, 2011 1:36 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.227s | 14 Queries | GZIP : Off ]