Detect collision between a moving object and an immobile one

瘦欲@ 提交于 2019-12-05 08:14:42

As a starting point, have a look here.

http://www.flipcode.com/archives/Theory_Practice-Issue_01_Collision_Detection.shtml

This is a very good introduction about all the different collision ways. Maybe your case is explained here.

I think this link: http://www.gamasutra.com/view/feature/3383/simple_intersection_tests_for_games.php might be what you're looking for. It describes the sphere-plane sweep test, useful for when you have fast moving objects that may pass through a plane within a one-frame interval.

It gives you the intersection point as well, which you can use to reflect your trajectory about the plane normal and continue the path of the object.

You are having problem with the fact that if one object is too fast, it can pass the immobile object before an Update() is called with the detection (like it passes through the immobile object).

Extend the shape of the object along the move vector with the size of speed: Square [0,0][2,2] with velocity [1,0] and speed 10 will create a shape of Rectangle [0,0][12,2] => it is now positioned at coords [0,0] with size [12,2].

Now intersected the rectangle with the immobile object. Now you know if they collided.

If two point objects have the same position, then they have collided.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!