Opening doors both ways

You could also make a dot product with a vector coming from the position of the door and the player and the forward vector from the door.

If the dot product is > 0, open backwards the forward door’s vector, is it is <= 0, open it towards.

Something like this:



if ( dot ( door.pos - player.pos , door.forward ) > 0 )
      //open the door backwards forward vector
else
      //open the door towards forward vector