Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

3 Dimensional Chat / Gravity

Author
Message
Moggie100
21
Years of Service
User Offline
Joined: 15th Oct 2002
Location: Behind You...
Posted: 6th Jan 2003 23:16
Is there a simple way to calculate movement due to gravity if you know the height of the object jumping and the ground height?
(Sounds like a noob question dont it?, I know, its just that I've never made a game with proper gravity before lol)
Life is like a hot bath, the longer you're in it, the more wrinkles you get.
Moggie100
21
Years of Service
User Offline
Joined: 15th Oct 2002
Location: Behind You...
Posted: 6th Jan 2003 23:17
NB. I'm using BDP so DBP commands I can use

(damn I h8 not being able to edit posts )

Life is like a hot bath, the longer you're in it, the more wrinkles you get.
Kangaroo2
21
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 7th Jan 2003 00:04
Not a simple way to genuinely calculate a type of gravity but plenty of ways to creat easish gravity effects with maths and variables as you are probably hoping you don't have to

* If the apocalypse comes, email me *
Moggie100
21
Years of Service
User Offline
Joined: 15th Oct 2002
Location: Behind You...
Posted: 7th Jan 2003 21:54
I dont mind the maths or vars, its just I've tried everything I can come up with!

Life is like a hot bath, the longer you're in it, the more wrinkles you get.
Kangaroo2
21
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 7th Jan 2003 22:24
Ok, well tell me:

A: the type of game you're making
B: how you're making it
C: what "gravity" effect you want, and in what cirumstance

And I'll try and help you in the right direction.

* If the apocalypse comes, email me *
Dr DooMer
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 7th Jan 2003 23:20
Well, I've made a gravity code for a little graphical thing on my next game's main menu. Lots of little particles, each of which calculates its distance and position from every other particle in the system and hence, though trigonometry (don't I love using that word?), can determine the effect of each gravitational pull.

Although, that's probably more complex than what you wanted to see. The height/size/mass of the object will not affect its descent due to gravity; only very light objects which have a high air resistance (like a cloth or feather, for example) will fall at a speed less than about 9.8m/s/s. For he non-physicists, that means that every second, the velocity of the object will change by 9.8 meters per second, providing there are no other forces acting on the body.

The distance from the ground does make a difference; however, if you're just making a game based within the Earth's atmosphere, you needn't really worry about this.

Anyway, this is probably what you actually wanted to know: store the object's vertical velocity in some variable, say "vel_y" for now (Y being the vertical axis). Now, every frame you will add this velocity value to the object's current Y position - a positive value will then make the object go up, a negative velocity will make it go down. Also, every frame that the object is in the air, you will subtract a set value from vel_y, making the object descend quicker each frame. To make to object jump, or be thrown, you simply set vel_y to a positive value, making the object travel upwards. While on the floor, you will not want the object to be falling anymore, so you'll want to set vel_y to zero every frame, meaning the object neither falls nor climbs.

There - hope this is of some help!

"I am a living, thinking entity who was created in the sea of information."
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 8th Jan 2003 01:25
I'd like to see that particle effect, Dr DooMer. Loads of particles, each attracting each other by gravity? How did you use trigonometry for that? Surely Pythagorean Theory is enough to calculate the forces (and probably less cpu intensive). Also I'm interested to see whether the whole system overbalances due to randomness and flies apart/away from the camera.

Note if you are using DB's collision, it sometimes can't tell whether the object is on the floor or not, leading to inaccuracies like incredibly high gravitational accelerations or being able to slide up walls by jumping against them.
Dr DooMer
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 8th Jan 2003 03:21
I've made it so when the particles move a certain distance from the centre point, their velocity is heavily dampened so, due to the other particles, they slowly travel back to the centre. To keep them moving, when two collide, they go f-zap and fly off in different directions. I probably did use Pyth's Theory for the distances, but I can't remember.

At first, they did fly off to places I didn't want them to go - they kinda clustered at first then bobbed off in one direction, then flew violently apart, then darted in the opposite direction, then got blasted over the whole screen, etc, etc.

Tomorrow, when I'm less tired, I'll extract the relevant code, make it stand-alone and then post it here for you.

"I am a living, thinking entity who was created in the sea of information."
Dr DooMer
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 8th Jan 2003 15:32
Well, here you go:



This has been made with DBClassic but will probably work with DBPro too. The original looks a bit better because I've used textured plains instead and you get a better view of the depth. I don't really mind if anybody uses this code for anything, but I'd like for you to tell me if you do use it. Thanks!

"I am a living, thinking entity who was created in the sea of information."
cybersamurai
21
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 8th Jan 2003 16:52
Sexy Code

Rusty Gears
Dr DooMer
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 8th Jan 2003 19:57
It's probably the only bit that looks tidy!

"I am a living, thinking entity who was created in the sea of information."
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 8th Jan 2003 23:59
I like that code . I tried something like it a while ago, a swarming effect, but using different maths, I didn't even use pythagoras, just a check between the x y and z values, and a corresponding change in velocity.
Arrow
21
Years of Service
User Offline
Joined: 1st Jan 2003
Location: United States
Posted: 9th Jan 2003 04:43
Damn, I need to take higher math.

This is Truth!
This is my Belief!
...at least for now.
Dr DooMer
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 9th Jan 2003 19:56
Well, I got a 'D' at A-Level maths, if that makes you feel any better. Stupid differentiation and integration...

"I am a living, thinking entity who was created in the sea of information."
Kangaroo2
21
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 10th Jan 2003 04:44
Nice code doomer
No reply from the mogster yet...?

* If the apocalypse comes, email me *
Arrow
21
Years of Service
User Offline
Joined: 1st Jan 2003
Location: United States
Posted: 10th Jan 2003 20:28
well I A'ced Algebra I and Geomirty (guess the grade I got in Spelling, LOL) but I had cruddy teachers whenis can to Algebra II so I barly got by with a D-. I got a 26 in math on my ACT, or is it SAT, whatever, I got a high score.

This is Truth!
This is my Belief!
...at least for now.
Moggie100
21
Years of Service
User Offline
Joined: 15th Oct 2002
Location: Behind You...
Posted: 12th Jan 2003 17:10
The mogster has been too busy as of late, and has therefore neglected to look at his own posts, lol.

Anyhoo, I'm back now. Time for a read...

Ok, here goes.

Dr DooMer - Very nice code

Kangaroo2 - You wanted some info. here it is:

Look at the following pic, if it doesnt appear, copy+paste the link below.

(Pleae note that for development purposes the graphics in this are kept low, so that I can work on the physics/gameplay without thinking about the objects, textures etc. alot of the objectcs are either ones I've done ages ago, or spheres)


or
http://www.geocities.com/weaponsmod/Pic.gif

The transport, near the center of the image, is currently hanging there, 4 units above the matrix.

The game itslef is online multiplayer only, with a variety of different vehicles that the player can get in and out of at will (that bits done ) each vehicle has its own controls and weapons, each loaded from a seperate file. At the moment, all the vehicles are a constant height away from the part of the terrain the are on, and given the explanation of having 'SureFoot' technology, which anchors them to the ground.

The problem is that the transport, as a flying craft, cannot have the 'SureFoot' excuse put in, since one of the things you can do when flying is that you can go up, and down in relation to the terrain based on the angle that you are flying at.

Basicly I want a gravity affect that will slowly make the transport sink downwards, accelerating as it falls, when the craft is stationary. I have tried using 'curvevalue' to calculate the increasing speed, and failed miserably.

I have a feeling that the answer's simple, its just that I cant see it lol

Thanks in advance.

Mog.

Life is like a hot bath, the longer you're in it, the more wrinkles you get.
Dr DooMer
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 12th Jan 2003 23:00
Picture isn't available; you sure you got the link right? Or am I making another blunder?

"I am a living, thinking entity who was created in the sea of information."
Kangaroo2
21
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 12th Jan 2003 23:22
The pic works for me

Ok I'll write a simple(ish) code soon, when I have time

Moggie100
21
Years of Service
User Offline
Joined: 15th Oct 2002
Location: Behind You...
Posted: 13th Jan 2003 00:47
Dr DooMer - the address for the pic is below the pic, copy + paste that into u're address bar. Should work, worked for me anyway

Life is like a hot bath, the longer you're in it, the more wrinkles you get.
Dr DooMer
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 13th Jan 2003 03:26
Nope, still can't get it; I'm probably doing something wrong. Oh, well - I'll settle for the next best alternative:

Kangaroo, does the pic look good?

"I am a living, thinking entity who was created in the sea of information."
Kangaroo2
21
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 14th Jan 2003 21:18
Hi Doomer this picture is hard to classify as "good" or "bad" because its obviously very early. Its a nice enough low poly ship on a basically plain marix with a black background. Seemingly no textures yet.

Moggie100
21
Years of Service
User Offline
Joined: 15th Oct 2002
Location: Behind You...
Posted: 14th Jan 2003 21:26
"(Pleae note that for development purposes the graphics in this are kept low, so that I can work on the physics/gameplay without thinking about the objects, textures etc. alot of the objectcs are either ones I've done ages ago, or spheres)" - Myself

The reason for the lack of textures, or much else in the way of graphics is that:

1: Its early days.
2: The guys making the textures haven't sent them to me yet.

3: I'm running on a v.low tech graphics card, an ATI Rage 128 pro, and its showing its age. Even a simple scene, consisting of a matrix and 2 particle effects drops my framerate to about 10fps.

The advantage of this is that I can be sure that my programs will run on pretty much everyone's PC's if it will run on mine

Life is like a hot bath, the longer you're in it, the more wrinkles you get.

Login to post a reply

Server time is: 2024-03-28 20:37:19
Your offset time is: 2024-03-28 20:37:19