what is the best way for gravity
Blitz3D Forums/Blitz3D Beginners Area/what is the best way for gravity
| ||
yes i know i have been posting alot and yes i know that i posted it in another forum (but it was the wrong one)but i'm just starting and i can't figure out some of these things but anyway what is the best way for gravity u could give me an example or if there is a tutorial i don't know about that will work too |
| ||
Just have your thing you want to be 'gravitized' (I know... It's not a word... but bear with me... and if you don't understand the meaning... its 'to be applied with gravity' :o) ok...) and make it move down everytime. Put '' MoveEntity guy,0,Gravity_speed#,0 '' into your code in the main loop. Do you also need help with collisions? So if he goes down, like I said, he wont fly through the ground? If so, feel free to ask in this thread and I'll get a demo working for you with your gravity and collisions. |
| ||
i tried that and i can't get it to work, can u just make the example for me that will help thanks, Rubiks14 p.s here is my sourcecode so u can try to make it fit in ;graphics Graphics3D 800,600 SetBuffer BackBuffer() ;GLOBALS Global x#,y#,z#,terra_y# ;collision groups Global SCENERY = 1 Global PLAYER = 2 ;light Global light = CreateLight() RotateEntity light, 90,0,0 ;CAMERA PIVOT camera_pivot= CreatePivot() EntityRadius camera_pivot,1.4 EntityType camera_pivot,PLAYER ;CAMERA Global camera = CreateCamera(camera_pivot) CameraRange camera,1,1000 CameraFogMode camera,1 CameraFogRange camera,160,200 ;SKY Global sky = CreateSphere(16,camera_pivot) FlipMesh sky ScaleEntity sky,100,100,100 PositionEntity sky, 0,50,0 sky_tex = LoadTexture("sky.bmp") EntityTexture sky,sky_tex ;TERRAIN Global terrain = LoadTerrain("height2.jpg") TerrainDetail terrain,2500,True ScaleEntity terrain, 3,100,3 PositionEntity terrain,-1000,0,-530 ter_tex = LoadTexture("mossyground.bmp") EntityTexture terrain,ter_tex EntityRadius terrain,0.2 EntityType terrain,SCENERY ;main loop While Not KeyHit(1) ; use the mouse to look around TurnEntity camera_pivot,0,-MouseXSpeed()/5,0 TurnEntity camera_pivot,MouseYSpeed()/5,0,0 RotateEntity camera_pivot, EntityPitch#(camera_pivot),EntityYaw#(camera_pivot),0 RotateEntity camera_pivot,EntityPitch#(camera_pivot),EntityYaw#(camera_pivot),0 MoveMouse GraphicsWidth()/2, GraphicsHeight()/2 ; use the w,a,s,d or arrow keys for walking and strafing If KeyDown(17) Or KeyDown(200) MoveEntity camera_pivot,0,0,0.10 If KeyDown(31) Or KeyDown(208) MoveEntity camera_pivot,0,0,-0.10 If KeyDown(30) Or KeyDown(203) MoveEntity camera_pivot,-0.10,0,0 If KeyDown(32) Or KeyDown(205) MoveEntity camera_pivot,0.10,0,0 x#=EntityX(camera_pivot) y#=EntityY(camera_pivot) z#=EntityZ(camera_pivot) UpdateWorld terra_y#=TerrainY(terrain,x#,y#,z#)+2.0 PositionEntity camera_pivot,x#,terra_y#,z# RenderWorld Flip Wend End |
| ||
I beleive by using this code that you wrote, you are trying to align the player to the terrain using the following command. Right?PositionEntity camera_pivot,x#,terra_y#,z# What do you need gravity for if the player is always aligned to the terrain? There is no need for it... I don't know... if I'm wrong, sorry... its 2:30 in the morning... 4 hours until I wake up from sleeping... so I'm very tired... And I don't think straight when I'm tired... ok... hope that was right. I need to go to bed... or maybe I should work on my physics simulator/editor... hmmmm... tough desicion... probably sleep... don't want to mess it up because I fall asleep on the keyboard and delete my files... and then have my drool from me sleeping get in the keyboard and have the keyboard electrucute me.... :P |
| ||
well i thought that u had to have gravity to bring someone down from a jump |
| ||
Derek, did you ever take a look at my basic FPS code at my website? It has some basic gravity in it (but not jumping, but that's not too hard to add). http://home.cmit.net/rwolbeck/programmingtutorial |
| ||
yea some but i couldn't really understand some of it, i'll look over it again....i now no y i didn't because since i didn't have the latest version of blitz3d it wouldn't let me run it but now it does and i can understand it better |
| ||
Rubiks, you basically need a speed and acceleration factor. You add the acceleration to the speed and the speed to the y to simulate a jump. Here is some code I'm typing off the top of my head so probably wont work as-is, but should give you the general idea.speed# = 10 ;these will change depending on the level, scale accel# = -.5 ;what's jumping, etc... while not keydown(1) if jump = true y# = y# + speed# speed# = speed# + accel# if y# < terra_y# y# = terra_y# jump = false end if end if PositionEntity camera,x#,y#,z# RenderWorld Flip Wend |
| ||
or...local yforce# local gravity#=.1 while not keydown(1) if keyhit(57) ;Jump yforce = 20 endif if entitycollided(entity) yforce = 0 endif yforce = yforce - gravity moveentity(entity,0,yforce,0) updateworld renderworld flip wend Perfecto Jump! |
| ||
i've tried doing something like both of those and my camera will just barely jump i mean like just enough to notice it's goin up |
| ||
You need to fiddle with the values a bit. If you are not jumping high enough, try decreasing the effect of gravity. If your jumps are too slow, try increasing the initial velocity. Just mess with those two values til you get something that looks good. |
| ||
what is the best way for gravity Um, down. :) |
| ||
*RossC steals a wheelbarrow full of beer from Gfk, then runs into the night! Also, the best way for gravity is down, so i agree with Gfk :D (he knows all about gravity) |
| ||
So, if a big hole was drilled all the way through the center of the earth to the other side, then you jumped into the hole, what would happen? Would you eventually come out the other side? Would you end up suspended in the center of the earth? Let's assume you have a heat resistent, pressurized suit on so buring up on magma or being crushed to death won't happen. |
| ||
The hole could never be dug, because it would cause a volcano to appear. |
| ||
If the centre of the earth were hollow and of uniform density then you would you be weightless at the exact centre? Or would you be effected by the pull of the moon? And if the moon would suddenly dissapear when would we notice? Immediately, or a fraction of a second later? What is the speed of a graviton? Does a graviton exist? Who knows? Who cares? As long as down is down I am happy (as long as I am not over TomToads hole of course). Hey, Toad in the hole, (yum)! |
| ||
I'd imagine there must be a time between that. I think everything travels at some speed or other. :o) |