Collision with User Input and Object

  • Collision with User Input and Object NebulaFox

    I am curious on how to handle collision detection involving a moving target and user input. Basing myself in the mobile space, I get events from a set framework, but I do wonder about the amount of lag involved.

    Say the object moves faster and faster, then position of the input and the object is very important. What I want to know is what is the best design for handling user input and then also the best way to make sure to accurately work out when the input point collides with the object, keeping threads in mind?

  • Your question is so vague that it cannot really be answered. However, you sound new so I'm going to try and help. Here is what I suggest you do if you truly want to make computer games:

    I am curious on how to handle collision detection involving a moving target and user input... but I do wonder about the amount of lag involved.

    Your first question tells me that you really need to read up on your Matrix mathematics, in all non trivial cases it will come down to some small Maths to work out if the users press on the screen was on an object. Usually by firing a projection through your world starting at the camera and seeing if it collides with anything. For Matrix Maths knowledge and vector calculus in general start with this good guide: Vector Math Tutorial for 3D Computer Graphics. (Those sixteen chapters give you the basics and it should take you a few months to learn that properly.)

    About the lag issue: Maths on Computers is usually ridiculously fast. If you can find a good way to do it using some Maths then, in general, it will be fast code and result in little in the way of lag. If you suffer more lag despite that then it is probably an algorithmic problem and you should look into Complexity Theory and see if you algorithm are fast enough. All you probably need most of the time is Big-O notation and here is a good introductory tutorial (though there are better notes out there).

    Say the object moves faster and faster, then position of the input and the object is very important. What I want to know is what is the best design for handling user input and then also the best way to make sure to accurately work out when the input point collides with the object, keeping threads in mind?

    Once you know the Math, knowing how to handle collisions with 'jumping' objects due to high speed is relatively easy. Ask a new question about that specifically if it does not come easily to you; but only once you have read that Vector Calculus math above.

    There is no 'best designs' for handling user input in games, just methods that work well for your particular game. Just try and make the simplest thing that will work and improve them only if you need to.

    Now accuracy in video games! That is a real problem and one that requires true concentration and skill, if your game needs a high level of accuracy, and you are using floating point values like 'float' and 'double' to represent things then you will need to learn how to deal with those properly too otherwise you will see serious and subtle problems occur in your games. I would recommended looking at: Comparing Floating Point Numbers and other good articles on the topic too to see if, and how, it will effect you.

    As for concurrency, well that completely depends on what parts of your program you think you can make concurrent and how you do it. Just minimise shared state and everything will be easier. There are concurrency best practices out there and they are included in any good concurrency tutorial, the rest is left as an exercise to the reader.

    In the future, try and ask smaller questions with more details because it raises the possibility that somebody will be able to give you a definite answer. Keeping that in mind I hope this answer help and you should note that the road to game development if filled with learning many different and new topics so it will take some time but, if you enjoy programming, then it is a extremely fun journey.

game-design c++
Related questions and answers
  • Currently in my project, the way I handle user input events is through the OS Framework, then create a generic object - basically combines all types of input: keyboard, mouse, touch, trackball, etc... that I have generated. I handle the threads by using turn-based concurrency. My problem is I worry about lag of the input events when there are fast moving objects, and I am curious to see if there are better ways of handling the input events then currently? My current idea, of handling the simple hit test of fast moving objects with user input, is that I try and use the timestamp generated

  • Sorry for the ackward title, but i don't know what to call it exactly. I'm looking for code or libraries that allow easy creation of commonly used user input devices, and code/libs that make gaming controls easy to set up (i'm using SFML and Box2D at the moment) I don't want to re-invent things like buttons, arrows being placed wherever the mouse is located, and more game specific items... or resources out there that i can use to avoid spending much of my time coding these now standard input devices/tecniques?

  • Collision Resolution ultifinitus

    ," on the stack. What's I think is happening is the object's collision system checks and resolves for collisions based on creation time, so If I check one axis, then the other, the object will "sink" object directly along the checking axis. This sinking action causes the collision detection routine to think there's a gap between our position and the other object's position, and when I finally check...Hey all, I'm making a simple side-scrolling game, and I would appreciate some input! My collision detection system is a simple bounding box detection, so it's really easy to implement. However my

  • ]; // nx, ny, nz; float colour[4]; // r, g, b, a float padding[20]; // padded for performance }; I've already written a working VertexBufferObject class that creates a vertex buffer object from an array of CustomVertex objects. This array is said to be interleaved. It renders successfully with the following code: void VertexBufferObject::Draw() { if( ! m_bInitialized... ); glDisableClientState( GL_COLOR_ARRAY ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); } Back to the Vertex Array Object though. My code for creating the Vertex

  • First theoretical question. What is better (faster)? Develop your own gpgpu techniques for physics simulation (cloth, fluids, colisions...) or to use PhysX? (If i say develop i mean implement existing algorithms like navier-strokes...) I don't care about what will take more time to develop. What will be faster for end user? As i understand that physx are accelerated through PPU units in gpu...-theoretical question: Is physx able to do sofisticated simulation equal to lets say Autodesk's Maya fluid solver? Are there any c++ gpu accelerated physics frameworks to try? (I am interested in both physx

  • Possible Duplicate: Are there existing FOSS component-based frameworks? What open source game engines with component-based design of game objects do you know? And which best of them? I mean best not in Graphics or Physics, but best in context of Behaviour, Messaging, etc. This question is the result of inspiration by another question Thank you!!!

  • I am trying to create a 2D platformer (Mario-type) game and I am some having some issues with handling collisions properly. I am writing this game in C++, using SDL for input, image loading, font loading, etcetera. I am also using OpenGL via the FreeGLUT library in conjunction with SDL to display graphics. My method of collision detection is AABB (Axis-Aligned Bounding Box), which is really all I need to start with. What I need is an easy way to both detect which side the collision occurred on and handle the collisions properly. So, basically, if the player collides with the top

  • not seem to have joystick input support, which would require that SDL or some other library also be used. So my question can be summed up as this: What is the best way to get SVG and joystick...I'm looking into building a cross-platform opensource 2D RPG style game engine for ChaiScript. I want to be able to do all of the graphics with SVG and need joystick input. I also need the libraries I use to be opensource and compatible with the BSD license. I'm familiar with allegro, ClanLib, and SDL. As far as I can tell, none of these libraries have built in or obvious integration for SVG

  • The problem is that I'm trying to use my meshes with Bullet Physics for the collision part of my game. When I attempted doing this method with my GLM(model loading library by nate robins) model, I get a segmentation fault in the debug, so I figured that it doesnt like the coordinate variables of the model. If i use blender to export my model as a collision file, what type of file should I use? I have heard of a .bullet exporter, but i dont know hot to integrate this python script into my Blender 2.5 program.

Data information