Simple Game Physics Question

Blitz3D Forums/Blitz3D Programming/Simple Game Physics Question

OrcSlayer(Posted 2004) [#1]
Ok, I know that title is a bit of an oxymoron, but I'm sure someone can help me out here...

What I want is a simple, built in physics system (in other words, no tokomak, no DLL's, no pain), similar to that used in unreal (original engine, not karma or anything). Basically, I want to be able to give an object a push from things like, say an explosion, that will fling entities into the air and basically all the good chaotic stuff we remember from Unreal/UT. I'm sort of familiar with the concept of giving an impulse with a certain amount of force, from a certain position (explosion position), and having that effect the entity. Now, I know this isn't nuclear fusion science, I've seen it in games all the way back to Marathon (which was released in, what, 1992?). Maybe even before that. If anyone can give me some advice on how to code this, and maybe some references to articles on the subject, I would be most grateful. Math was never a strong point for me...


sswift(Posted 2004) [#2]
http://www.blitzbasic.com/Community/posts.php?topic=34953


OrcSlayer(Posted 2004) [#3]
Yikes...I have a lot of reading to do tonight... Looks like this is exactly what I was looking for, thanks for the assistance!


Kalisme(Posted 2004) [#4]
Actually, I'm using Tokamak...
I'm a 15 (soon 16) year old programmer and I think it's the easyest lib I've ever used! I'm currently writing a ragdoll editor for my current project... Just sit down and read some of the tutorials.. it's suprisingly easy!

-just my suggestion


BlackD(Posted 2004) [#5]
Wow!

sswift is a genius. Just read that entire linked thread. :) Nice stuff.


OrcSlayer(Posted 2004) [#6]
Wow, I'm in pain from reading that. I can understand some of it...but this stuff is way over my head. I think I'll be needing some help with this stuff...


OrcSlayer(Posted 2004) [#7]
Ok, I had an idea. I created a simple test program (no media, and in a single file), with a similar framework to my program. If I posted it on here, think you could "fill in the blanks" on how to make it act like a typical FPS engine? Basically, it has an ellipsoid player, a large hollow cube for a room, a staircase, and a ramp. Very bare bones, but I think this could be very useful to me, and anyone else wanting to see how it's done in a very small scale test. If anyone wants to take up the challenge, let me know and I'll post it. Just for the record, how does one create a code box in your posts? I used to know the command, but I never used it before and I don't remember it...


Ross C(Posted 2004) [#8]
(codebox)

code her

(/codebox)

or for the one with no scroll bars..

(code)

code here

(/code)

Replace () with []

:o)


OrcSlayer(Posted 2004) [#9]
Ok, well here's what I put together.



What I'm looking to do is give the player realistic gravity, the ability to give objects like the player a push from outside forces (to knock them around with explosions and such), and the ability to have objects rebound from surfaces. If anyone would like to help out here, major thanks are in order. Free copy of the finished game and name in credits too of course.


OrcSlayer(Posted 2004) [#10]
Ok, looks like I have bouncing object physics figured out. I'll try adding some bouncing objects to my demo and see how that works.


GW(Posted 2004) [#11]
This is what worklogs are for...


OrcSlayer(Posted 2004) [#12]
This isn't a worklog, it's a help request...


OrcSlayer(Posted 2004) [#13]
Ok, last bit of help I need...I have bouncing objects working, but I'm not quite sure about one point. Since instead of using moveentity I'm adjusting x, y, and z velocities, I have no clue how to decide exactly what direction the object is aimed at when I create it. I know the exact direction, as in rotateentity direction, that I want the object to intitially move in, how do I convert that into the needed x, y, and z velocity?


sswift(Posted 2004) [#14]
After rotating your object, transform it's velocity vector, which you want to point in the direction of your object, which is where the object's Z axis points, from object space to global space:

TFormVector 0, 0, Velocity#, Entity, 0


OrcSlayer(Posted 2004) [#15]
Ok, sorry I'm so dense on this issue...3D math is not my strongest point. I'm just going to post the code I'm using for bouncing objects (I found this somewhere else on the forums and modified it to add gravity, but even that doesn't work too well). If someone can please tell me how to make them start moving in the direction they are pointing, I'd be very grateful. Also, if someone can tell me where I'm going wrong on gravity...when balls run out of y velocity they stick to the ground like glue, even though they should have some x and z left in them.




OrcSlayer(Posted 2004) [#16]
And if there's a simpler/more efficient way than what I'm doing, please let me know.


sswift(Posted 2004) [#17]
I don't have time to correct your code but here is code for my own game with a ball that can bounce properly off surfaces, and is afftected by gravity and air friction. I haven't incldued the include files, but the physics code is all there, so you can just copy that and modify it to suit your needs.




OrcSlayer(Posted 2004) [#18]
Thanks for all the help guys, and I'll take a look at that code sswift, and see if I can figure it out enough to implement it...sorry I have such a hard time figuring out this 3D math. I haven't really needed it until now thanks to the many useful features in Blitz. I can actually fake the effect I'm after, to some extent. But, I hope I can make this work...it's so much better to use the real thing...