Flexman Posted December 6, 2013 Share Posted December 6, 2013 I remember that change. Really screwed up our game as we do ray casts at altitude for targeting, weight on wheels, radar altitude. Every time you passed over an entity the game would pause as the engine built some internal structure. All is well now though. Raycasting for ballistics, physics for feedback (sometimes, depends on the context). Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
YouGroove Posted December 7, 2013 Share Posted December 7, 2013 @NAughty Alien : It depends if your bullets move fast or too much fast. With reasonnable speed physics works, in games where you see the bullets, missiles moving. If your bullet is fast like a real one : indeed rayscasting is mandatory, it would be non sense to use physics. But if you want moving bullet/missile you can see moving than physics should be possible. @ZioRed could you post some code and minimal scene example for us to test ? To see how fast your bullets are moving ? ------------------------ Some working math collision detection based on sphere-sphere (independent on speed) : For the player ,and the bullet if you use math 3D sphere for collision : You can use some simple cubes maths collision detection first than switch to more precise sphere-sphere collision detection once cube-cube are colliding. And apply that formula to 3D : ( ( x - a ) ² + ( z - b ) ² = r ², where ( a , b ) : center of cylinder r : radius of cylinder -------------------- Difference vector (the length is the distance between those two spheres): Then the length is computed: Sum of the radiuses: If distance<sumradius the we have a collision to take care of. http://studiofreya.com/blog/3d-math-and-physics/simple-sphere-sphere-collision-detection-and-collision-response/ 1 Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Naughty Alien Posted December 7, 2013 Share Posted December 7, 2013 @YouGroove ..i'm not trying to prove you wrong or anything like that, but i just think you misunderstanding how whole thing works, as math you writing doesn't mean much considering fact that physics cycles are independent from renderer and independent from logic cycles...this is where is trouble with accuracy, not in math behind trajectory/distance calculations..also, square root is a thing you will avoid at any cost in your loops.. Another trouble is physics engine used itself. If you really want your code to be elegant and easy to port, you will NEVER EVER create fundamental part of your game play, entirely dependent on to any particular development tool API, in this case physics, because in case of porting and been forced to utilize entirely different physics engine, that will be actually, rewrite of entire code base, attached to particular physics engine, and even worse, output results may look different as different engine is used and you entirely rely on it. I have seen it myself between Newton and Bullet, as well as Havok (trial)..practically, entire API for game is changed and hardly will look identical..it is advisable to write your game code, at least part what does matter, any API agnostic, much as possible, and ultimatively, that will give elegant solution of bullet issue, discussed on this topic.. 1 Quote Link to comment Share on other sites More sharing options...
ZioRed Posted December 7, 2013 Share Posted December 7, 2013 @NA: Trust me, I understand your thoughts and I know the issues in relying on physics, but I have many ideas of games where physics plays a very important role in the gameplay and of course I don't like to reinvent the wheel and definitely don't like to use raycast on each update to only understand if a rigidbody collides with something, this is the role of a physics engine else it would be completely unuseful. For example my latest game Domino Rally (http://itunes.apple.com/us/app/domino-run/id663200322) is almost completely relying on physics and it works pretty well without any "hack", it just works with forces and physics, so this is an example where you can perfectly rely on physics if it works as expected. I'm almost disappointed that I cannot rely on physics, I'm not the best math or physician in the world, neither I want to achieve a degree in Math or Physics Engineering to make a game (also consider that as already told I'm having very high FPS and unless the physics engine is completely broken then I should have collisions detected as expected because I'm not using very high velocity or very thin objects, I mean the bullet is thin BUT the avatar model is deep enough that it's really impossible that the engine won't intercept the collisions). I'm almost sure that my setup is wrong somewhere, because LE engine should hopefully implement physics correctly. Besides the fact that I'm not interested in porting a game to other engines, in which case I'm perfectly aware that it could lead to some changes to your code (well I implemented a component system and game engine, so if I had to change engine it would require changes to only 1 function, this is "API agnostic" too even if it relies on physics instead of math distance/collision detection). So to not being forced to hold on, I opted to switch to continuous raycast along the movement of bullet, this is working of course, even if it's not what I was trying to test. So for now I'm following this path and hopefully will release sooner a game demo, just some weeks to build few levels. Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
YouGroove Posted December 7, 2013 Share Posted December 7, 2013 is almost completely relying on physics and it works pretty well without any "hack", it just works with forces and physics, so this is an example where you can perfectly rely on physics if it works as expected. I agree, there is plenty of games relying totally on physics. All depend on what you do with physics and if you don't use physics in "special cases" @Naughty Dog : Some games asks you to install Physix Driver to play the game, even AAA game. So yes games relying on physics a lot exists, and companies making a game choose one 3D physic engine only once for all for their game. Raycast is physics engine part and all FPS games rely on that, so yes almost all FPS games have gameplay depending on physics. Racing games depend entirely on physics also. ---------------------------------- The math formula i put is math, there is not physic at all, you can calculate any frame, at each game loop if collision occurs. But i agree you must go RayCast if your small sphere move too much fast each frame , it will go through other sphere next frame loop and you don't have collision detected. The best is indeed to use Ray cast to detect if the ray hit something between previous and next game loop frame. ------------------------------- About sphere collision it won't cost a lot if you use cubes first to detect what sphere can collide with another, cubes will decrease the number of possible sphere collision first. Not convinced by spheres , even used on GTA 3 game for example ? http://www.gtamodding.com/index.php?title=Collision_File_Editor_II Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Naughty Alien Posted December 8, 2013 Share Posted December 8, 2013 Shere in that picture looks like a creation of collision hull, and sphere is a bad choice for collision body check. Considering that shape of majority of geometry primitives, especially custom one, fit in to a sphere leaving huge gaps on sides, yet colliding with everything around, makes sphere not really best choice. Ever try to fit your character in to sphere and use it as I collider? There is nothing to be convinced with spheres. They have its place in game dev, but that place doesnt carry badge of ultimate collision check body. And regarding whole talk about collision checks and math behind, in AAA games I was able to study code from, there is a tons of nasty clever tricks used for all sorts of checks, and square root and similar checks are rare as dinosaurs today..only here and there some remaining of it. Its just my opinion based on what I saw and experianced on consoles as they are not as forgiving as pc is when we talk development. All this things I mentioned, really matter in that hardware poorer environment. So whatever you see works on pc, doesnt necessarly means that works same on consoles. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted December 8, 2013 Share Posted December 8, 2013 Well that sphere system worked on GTA3 game , a game that was on consoles first, is also on mobiles. All depends on how you use your collision system and what you do with it. About consoles thye rely on physic engines like Havock for example, not always on their own tricky physic engine. http://www.havok.com/customer-projects/games?product=Physics Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Naughty Alien Posted December 8, 2013 Share Posted December 8, 2013 Okayyy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.