1
\$\begingroup\$

I am making a simple first person 3D game in OpenGL with C++. I am just wondering on how you make an object stop moving when it collides with another object. This is what I am using for detecting collisions:

a = object1
b = object2
w = width
object1 is moving on X,Y,and Z axes from user input

if( a.x + a.w > b.x && a.x < b.x + b.w )
(and the same thing for X, Y, and Z axis)

After detecting this collision how would I make "object1" stop moving?

\$\endgroup\$
3
  • 2
    \$\begingroup\$ We have lots of past Q&A about collision-resolution — what have you tried based on your research thus far? \$\endgroup\$ – DMGregory Jul 21 at 21:23
  • \$\begingroup\$ You use a c++ physics engine? \$\endgroup\$ – Vaillancourt Jul 21 at 21:29
  • \$\begingroup\$ It would help if you provided some info about how movement is being applied to object1. \$\endgroup\$ – Pikalek Jul 22 at 1:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.