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?

  • 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 '21 at 21:23
  • \$\begingroup\$ You use a c++ physics engine? \$\endgroup\$
    – Vaillancourt
    Jul 21 '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 '21 at 1:04

You must log in to answer this question.

Browse other questions tagged .