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.

Newcomers DBPro Corner / I've coquerred my fear of gravity, so I will share my solution!

Author
Message
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 16th Dec 2005 03:08 Edited at: 16th Dec 2005 03:11
Ok, I've been having problems with basic gravity lately... but I just now, without the help of any tutorials, made it work on my own. So here is the code, commented for anyone else with my problem.

And I will be working on collision next, so stay tuned!

EDIT: I meant conquered!



AMD Athlon 64 3200 - GeForce 6800 GT - 320GB Hard Drive
1024MB RAM
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 16th Dec 2005 03:16
Good job, and tell me if you've conquered collision. I wont be expecting that for a year. Really, collision always got me puzzled, I never got it right.
Sho Ryu Ken
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 16th Dec 2005 03:18 Edited at: 16th Dec 2005 03:22
Good, however you need code that determines the ground height for given x or z values (for terrain that's not flat). Y can make a difference too but only if there are multiple levels of height (think platforms) are included. Note that that means that one x and z coordinate can have two or more ground level y's. Then make it so that if it's ABOVE groundheight, it goes into a fall. At the stage this program is in, that's not so important but if you have sudden dropoffs or platforms the object will transfer right to the next level without falling. All this info I've gotten from my experiences in 2D, making a game with platform and such. But this is definitely a great start!

EDIT: I tried it out. You can also make the cube's position to be changed in midair by letting the controls work regardless of whether the cube is jumping or not. Or you can make another set of control commands that move it at a different speed in midair. (Useful for first person shooters.)
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 16th Dec 2005 03:21
I've already had some experience in collision, and I'm going to use simple block collision. What I am going to do (and I'm not going to do terrainsyet ) is make it so gravity only affects you if you are in the air and not colliding with a platform.
Thankyou for your feedback guys

AMD Athlon 64 3200 - GeForce 6800 GT - 320GB Hard Drive
1024MB RAM
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 16th Dec 2005 15:33
Quote: "` Make our cubic friend.
` Make a pretty and colorful box for absolutely no reason!
` Make the box translucent! OOOOH!!!
` Color our cubic friend so he isn't ugly anymore
` Movement... yeah yeah... Can only move if on ground though!
` Update our little cubic friend's position, so its not like hes in a coma!
` Guess waht sync does! It syncs!!!
"


I've never seen such lively remarks.

Immunity and Annihalation makes Immunihalation...
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 16th Dec 2005 22:09 Edited at: 16th Dec 2005 22:11
Lol, I don't know what I was thinking, guess I was just trying to get a message across... Is my commenting clear enough? I usually don't comment so it may not be very useful...

AMD Athlon 64 3200 - GeForce 6800 GT - 320GB Hard Drive
1024MB RAM
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Dec 2005 04:19
It's obvious that you were using a flat terrain in your program, without even running it - by your use of just one line in your program:

position matrix 1,-50,0,-50

Just a suggestion, but a helpful little tip is "Don't do this"!

It's OK with a flat matrix, but once you deform the matrix, you will find that Get Ground Height() stops working. Actually, it doesn't but you will think it has because it returns values from the matrix in it's original position and you have to compensate for it's new position when you use Get Ground Height() and it gets confusing.

So, you are better off leaving it where it is and position the object(s) in the centre of the matrix instead.

BTW, if you ever do need any objects at 0,0,0 you don't have to position them because that's where they appear by default when DB creates them.

TDK_Man

MMORPG programs
18
Years of Service
User Offline
Joined: 12th Nov 2005
Location:
Posted: 23rd Dec 2005 00:11 Edited at: 23rd Dec 2005 00:12
whenever i try it... nothing happens when i try to jump. Also i dont like the movement on ground only thing. Do this

Also when you do this you can take a large part out of the code. also if youve mastered gravity then you should slow down as you get closer to the top of the jump. Dont say you've mastered something if you havent. Also with gravity you need health to show the shock.

you really havent mastered gravity...
[edit]
bump
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 27th Dec 2005 01:17
Fool, I never mentioned mastering gravity, no one on earth has mastered gravity. I said I've conquered my fear of gravity. So learn to read before you criticize others writing. As for the matrix code, this is a demonstration of the gravity code I came up with, not of positioning matrices. I am a person who welcomes criticism with all his heart, as long as it is consrtuctive, no blatant and foolish.

AMD Athlon 64 3200 - GeForce 6800 GT - 320GB Hard Drive
1024MB RAM
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 27th Dec 2005 13:54
@TDK

Don't forget that you can get the ground height not from the positions you want, but the positions you want and adding the matrix offset, that would work properly.

x1b
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location:
Posted: 27th Dec 2005 15:57
Shadowed: very impressed. love the comments. I do such story board commenting as well.


Medival: Shadowed is right, think before you speak.

- Do it, Do it Right, Do it right now..
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 18th Jan 2006 22:42
Thanks guys, I've taken a break for about 23 days. And now I am working on making and texturing a matrix that the cube can "run" around on. I am having a few problems getting it to texture the matrix after I randomize it... But I will probably have that figured out soon. Thanks again.

AMD Athlon 64 3200 - GeForce 6800 GT - 320GB Hard Drive
1024MB RAM
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 18th Jan 2006 22:48
Oh, and @Sho Ryu Ken, thanks alot for
Quote: "Or you can make another set of control commands that move it at a different speed in midair. (Useful for first person shooters.)"
I didnt think of that before, I was trying to make it so if you jump while moving, your character would keep going the direction you were moving, at that speed, but you couldn't change direction in midair. Seeing as my code didn't do that, I will use a second list of commands that allows you to change direction but slowly, though if anyone could help me with keeping X/Z velocity in midair, but not changing it, please let me know.

AMD Athlon 64 3200 - GeForce 6800 GT - 320GB Hard Drive
1024MB RAM

Login to post a reply

Server time is: 2024-09-24 13:34:49
Your offset time is: 2024-09-24 13:34:49