Hit Detection When rotating the camera
- by SD1990
This bug/feature has been plaguing me for a while and i want to know the best way to fix it.
I'm testing simple hit detection with a wall, like:
if (Forward button)
if(Inv.w.z < -49 || Inv.w.z > 49)
pos.z = 0.0f;
else if(Inv.w.x < -49 || Inv.w.x > 49)
pos.z = 0.0f;
else
pos.z = +1.0f;
where Inv.w. is the camera positions.
Now obviously when i now hit that certain point i can no longer move away from the wall or anywhere in fact. How can i change this code to allow for the camera to be turned away from the wall so therefore i should be allowed to move?
for example, the player hits the wall and i cant move until i turn around or to the side?
I know its something to do with velocity but im pretty new to this so please bare with me if this is easy.