Author Topic: Gravity - with (I hope) very minor code changes.  (Read 6651 times)

0 Members and 1 Guest are viewing this topic.

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Gravity - with (I hope) very minor code changes.
Quote
Originally posted by Black Wolf
This is news? :nervous:


I don't know if it's big news but basically you do deserve credit for solving one of the big FS2 impossibles :D

Quote
Originally posted by Black Wolf
This is interesting, but it doesn't really simulate the way gravity works in the distances we'd be talking about (ie. between 0 and, say, 10000 m on average ASL). If we set it up this way, stoppping a few meters above sea level would see you slam into the ground at some ridiculous speed... but there might be a way to adapt it so that you do fall a variable defined distance based onthe time since the fall started - if we could get FRED to trigger a flag every time the evnt statrs, but not when it repeats - that might be a bit more challenging...


I agree but that doesn't mean you can't use this for micro black holes or gravitic weapons. :D Either of those could a much smaller fall off distance.
« Last Edit: June 15, 2004, 05:23:23 am by 340 »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Lightspeed

  • Light Years Ahead
  • 212
Gravity - with (I hope) very minor code changes.
Quote
Originally posted by Black Wolf
This is interesting, but it doesn't really simulate the way gravity works in the distances we'd be talking about (ie. between 0 and, say, 10000 m on average ASL). If we set it up this way, stoppping a few meters above sea level would see you slam into the ground at some ridiculous speed... but there might be a way to adapt it so that you do fall a variable defined distance based onthe time since the fall started - if we could get FRED to trigger a flag every time the evnt statrs, but not when it repeats - that might be a bit more challenging...


I know, that would be ideal. But I think if you apply a good multiplayer my system would work well enough. (You'll need to use a logarithmic approach to the problem)
Modern man is the missing link between ape and human being.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Gravity - with (I hope) very minor code changes.
Wow, excellent work, Black Wolf. :) As karajorma said, I'm certainly glad to see people doing new stuff with the sexps. :nod:

I have two suggestions
1) Try using every-time in place of when.  I think it's coded to evaluate every frame.
2) As you know, gravity is proportional to the square of the distance, so maybe you could try something like this:
Code: [Select]
every-time
  true
  set-position
    Alpha 1
    get-position-x
      Alpha 1
    -
      get-position-y
        Alpha 1
        *
          5
          distance
            Alpha 1
            Planet
          distance
            Alpha 1
            Planet
    get-position-z

3) Have you tried firing an invisible beam with a negative force to simulate gravity?  It might be the smoothest current solution.

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Gravity - with (I hope) very minor code changes.
Not in the current setup, but I have experimented with negative mass tractor beams in the past. Never got them to work unfortunately.

The problem is a that our planets are actually flat planes rather than points, though we could use Get position Y again. Still, it runs into the same problem as lightspeeds - your speed would depend on your position, rather than the amount of time you'd spent falling. We probably will have to apply some sort of meethod like this, but I want to see if I can fiddle something with flag setting first - maybe change a variable every time your speed drops below X, and then setting up the change based on one of the time sexps. It's not likely going to work, but it'll be worth a try anyway.

BTW, I don;t think I have every-time on FRED - I'm assuming it's under conditionals with when? I just got sent a whole bunch of FSO related stuff in the mail though (Thanks Xelion!) so I may have a more recent version on disk somewhere to test that with.


Quote
Originally posted by karajorma


I don't know if it's big news but basically you do deserve credit for solving one of the big FS2 impossibles :D
 


It's not solved yet... *Points SCPers in direction of first post*

:nervous:
« Last Edit: June 15, 2004, 09:53:43 am by 302 »
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Gravity - with (I hope) very minor code changes.
Didn't realise the every-time SEXP had been committed yet. :D

I assume it's in the bob birthday build of FRED?

I'm going to have to do some experimenting tonight :)

BW: While it might not be solved, it's a major step towards having it work :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Lightspeed

  • Light Years Ahead
  • 212
Gravity - with (I hope) very minor code changes.
It does indeed rely on position rather than time you have been falling BUT it's at least a better fake then just applying the same thing everywhere :)
Modern man is the missing link between ape and human being.

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Gravity - with (I hope) very minor code changes.
Agreed, but the problem is that most of TIs fighting will be taking place close to ground level, and crashing into the ocean will be fatal. This is going to add a fair bit of challenge to the mission as it is, but I don;t want to make it insurmountable.

NB - for something like the 158th, where a lot of their missions would (I assume, based on their screenies) take place in the upper atmosphere, where the player isn't supposed to be mucking around down near the ground, it'd work well, and could probably be adapted fairly easily. But for the moment, I need a system that'll work for TI, so I want to spend at least a little while longer researching stuff before I settle down on anything. Keep in mind that the method I develop will not neccesarily have to be the method everyone uses.
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Lightspeed

  • Light Years Ahead
  • 212
Gravity - with (I hope) very minor code changes.
Thats why you should keep it to low multipliers. :)
Modern man is the missing link between ape and human being.

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Gravity - with (I hope) very minor code changes.
Updated FS2 and FRED

Has current-speed in it.
-C

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Gravity - with (I hope) very minor code changes.
Quote
Originally posted by Black Wolf
BTW, I don;t think I have every-time on FRED - I'm assuming it's under conditionals with when?
Yes, but it's not in FRED yet.  It's in 3.6, though.  Just change "when" to "every-time" using Notepad.

I'll take a look at doing actual gravity.  I think it'll be pretty straightforward to implement.

 

Offline Flaser

  • 210
  • man/fish warsie
Gravity - with (I hope) very minor code changes.
IMHO a simple constant acceleration for all ships would be enough to simulate gravity itself, since no atmospheric battle will take on speeds or heights where change of gravity is significant.

However, the lift - or the prolusion system that keeps an aircraft or aerospacecraft in the air would be more difficult to implement.

You need to take into account the position of the wings or elevating surfaces. The easiest solution I can think of is aplying an acceleration normal to those surfaces at all times - however the ammoun should be some function that uses current velocity.

The mission designer should be able to set the ammount of gravity, an individual factor of speed dependant lift for all crafts, as well a constant lift factor to simulate hovercrafts.
"I was going to become a speed dealer. If one stupid fairytale turns out to be total nonsense, what does the young man do? If you answered, “Wake up and face reality,” you don’t remember what it was like being a young man. You just go to the next entry in the catalogue of lies you can use to destroy your life." - John Dolan

 

Online Trivial Psychic

  • 212
  • Snoop Junkie
Gravity - with (I hope) very minor code changes.
If we do try to factor in lift for atmospheric flight in a gravitational environment, perhaps each ship should have a lift factor in its table entry.  The degree of lift would of course have to change depending on what angle the ship is to the gravitation source.  Perhaps the lift could be coded to be like a thruster on the underside of each lift-capable ship, so you wouldn't get lift in a dive that pushes you away from the gravitational source.  Also, the lift factor would also change depending on the actual speed of the craft.  I was going to say that the thruster would be tied into the main throttle, so that if you cut your speed, you lose your lift, but that eliminates gliding... so it would need to be tied to the ship's actual speed.

I'm not sure if that makes complete sense... but there it is.

Later!
The Trivial Psychic Strikes Again!

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Gravity - with (I hope) very minor code changes.
FS2 ships can slide up/down/left/right if configured, yes?

So, implement a command that toggles auto-firing thrusters to keep the ship level; this would include the main drive.

Ex: Johnny Bravo enters the mission area in his custom hoverbike, configured to auto-thrust. Without touching the controls, the craft simply floats at a speed of 0, while the bottom thrusters fire at 50%.

Then the Penguin fires a large bullet. Johnny dodges by moving upwards; the craft's bottom thrusters jump to 100% as he presses the "slide up" key, then drop back down to 50%.

The penguin fires another projectile, this time Johnny slides down; the bottom thrusters disengage and the top thrusters fire at 100%.

Johnny decides to fly away from the planet as fast as he can, so he turns his ship so its rear faces the planet. The bottom thrusters again disengage, and this time the main engines auto-thrust at 25%. Johnny hits the full-throttle button and the main engines engage at 100%.
-C

 

Offline ShadowWolf_IH

  • A Real POF Guy
  • 211
    • CoW
Gravity - with (I hope) very minor code changes.
why not reset the interval to ms instead of seconds, it would make for a much smoother transition on things like this.  besides, the send message list runs off of ms.

It would make things look alot less jerky
You can't take the sky from me.  Can't take that from me.

Casualties of War

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Gravity - with (I hope) very minor code changes.
But it would also destroy any events using the current repeat system. By decreasing the permitted interval, we can get the same effect without breaking anything.
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Gravity - with (I hope) very minor code changes.
Bumpo.

Don;t waqnna let this one go that easily :)
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Flipside

  • əp!sd!l£
  • 212
Gravity - with (I hope) very minor code changes.
It's a bit tough because no FS2 ships can really get up enough speed to stay airborne. You really need 2 values for speed 'physical' and 'absolute y', physical being what is shown on the HUD and absolute being the vessels absolute y velocity (I don't remember the maths, but it invloves a triangle of the physical speed, and time taken for measurement, and the opposite will be the absolute Y velocity iirc.)

If you could find a way of affecting the ships absolute y velocity decreasing it using a multiplier, you could have a gravity effect that works, at least for the way TI does it, it could give the 'wheelie' effect when a ship reaches it's ceiling, of the nose pointing up, but the ship not climbing.

That idea would take source code changes though :(

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Gravity - with (I hope) very minor code changes.
I think I know how you might do this.

Make a system, like the one for adding waypoints, that would add "gravity points".  Each point would have a characteristic acceleration affecting all objects in the area.  You might get some cool effects if you put a bunch of those in an asteroid field. :p

For atmospheric missions, we might specify "lift" on a ship-by-ship basis that would either counteract or reinforce the gravity.

 
Gravity - with (I hope) very minor code changes.
Goob: Perhaps a mission flag with lift multiplier. This way you could make a difference between flying in Jupiter and flying on an Earth like atmosphere.
just another newbie without any modding, FREDding or real programming experience

you haven't learned masochism until you've tried to read a Microsoft help file.  -- Goober5000
I've got 2 drug-addict syblings and one alcoholic whore. And I'm a ****ing sociopath --an0n
You cannot defeat Windows through strength alone. Only patience, a lot of good luck, and a sledgehammer will do the job. --StratComm

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Gravity - with (I hope) very minor code changes.
Different atmospheric lift... good idea.  Though from an air-resistance perspective, I'd think you'd want different plane designs in different atmospheres.