Maybe better here...
Blitz3D Forums/Blitz3D Programming/Maybe better here...
| ||
This is proving a LOT harder than I first suspected, so I thought maybe I'd have better luck here. Original post: http://www.blitzbasic.com/bbs/posts.php?topic=17097 I hope you can understand what I am trying to do. I wish to give the ship some form of inertia/momentum. I would like to maintain correct physical laws of motion etc, and have made prior definitions for ship mass/acceleration etc. Perhaps m*v for all three dimensions can be combined (with trig) to move in an overall movement in *a* direction, but although joker's code was just what I was looking for with regards to 2D, when trying to expand it to 3D it gets too complicated. I also thought of Integration to expand into 3D, but the maths just got far too complicated for me. It may be interesting to note that the ship Pitches and Rolls. It doesn't turn by Yaw. This does make figuring out it's actual change in orientation quite difficult, along with the fact that I think Pitch ranges from +90 to -90 or similar (as polar). Whereas Roll and Yaw both rotate -180-180 or 0-360...(see I get confused again!) Hope someone can help! Many Thanks. |
| ||
Use the physics code I posted. It will automatically update the velocity. All you have to do is enable physics and then move, and it will keep moving at that rate. You can make entities bounce, give them friction, gravity, etc. In the code below, the ship would keep moving after you had let go of the key:EnablePhysics ship While Not Keyhit(1) If KeyDown(200) MoveEntity ship,0,0,1 UpdatePhysics RenderWorld Flip Wend |
| ||
Sorry, Halo - Thanks for replying. Do you mean these physics? (if not, please give me a link to the correct ones!) |
| ||
have a look in the blitzcoder code archives, i posted some 2d asteroids physics in there, which is what you are looking for i think :) |
| ||
In my original thread (link in first post), joker gave me some code which simlates the 'asteroids' type motion in 2D. However, as my ship Rolls instead of turning on Yaw axis, it is difficlt to implement the 3rd Dimension. This is where the difficulty arises. |
| ||
ah i see, so you only have control of roll and pitch? my code is still easily usable by using tformvector. make sure you understand my code in 2d, then instead of using sin(angle)*thrust and cos(angle)*thrust, start with a tformvector 0,0,thrust,ShipEntity,0 once this is done, your x component of thrust is tformedx, your y component tformedy, and your z component tformedz. if you cant do it, let me know, and il do it for ya ;) |
| ||
Thanks DarkEagle. I got a bit lost and the ship moved, but in the wrong directions. I tried fiddling with the numbers, but jst made things worse. In the code (zipped in link), the main files to look at are : Config.bb MoveObjects.bb and Control.bb As it standsin the download, I have just assigned Speed# this is no good on its own. Some variables of note are: ship_total_mass=35000 ship_pitch=2 ship_roll=2 topspeed=50 speed_increment#=0.3 For Thrust, just suplement speed_increment# for now. Controls: v = change camera view CTRL = View Opject labels/debug info Joystick = move Joystick throttle = engines Thanks a million! |
| ||
If I create a pivot, and the pivot is what moves and carries the inertia, and if I can 'grab' the vector of the facing of the pivot, I could perhaps AlignToVector the ship to the pivot's vector smoothly. However, I don't know how to take the pivot's facing vector. |