### Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

### Topics - a6n0rma1

Pages: [1]
1
##### GLBasic - en / 3D Camera Collision Problem
« on: 2013-Jun-13 »
I'm making a silly little game, based on the 3dmaze sample. It creates a random maze, populates it with sprites and 3dmodels and let's you walk through the dungeon. I changed the deafult camera to enable moving with w,a,s,d and mouse looking on x and y axes. I added kanonet's super lighting lib and his quick math library. Everything is working fine, except i can't make a proper camera collision.

Code: (glbasic) [Select]
`x_old = Cam_x//store current x camera valuez_old = Cam_z//store current z camera valueIF X_COLLISION(0,0,sz/4,Cam_x,sz/2,Cam_z)//check if the camera collides with any of the walls. walls have id 0 Cam_z = z_old Cam_x = x_old collision = 1ELSE collision = 0ENDIFIF KEY(17)// forward 'w' INC Cam_z,qSIN(phi_xz)*Cam_Speed INC Cam_x,qCOS(phi_xz)*Cam_Speed ENDIF IF KEY(31)// back 's' DEC Cam_z,qSIN(phi_xz)*Cam_Speed DEC Cam_x,qCOS(phi_xz)*Cam_Speed ENDIF IF KEY(30)// left 'a' INC Cam_z,qSIN(phi_xz-90)*(Cam_Speed-0.2) INC Cam_x,qCOS(phi_xz-90)*(Cam_Speed-0.2) ENDIF IF KEY(32)// right 'd' INC Cam_z,qSIN(phi_xz+90)*(Cam_Speed-0.2) INC Cam_x,qCOS(phi_xz+90)*(Cam_Speed-0.2) ENDIF`
I then print the collision value. Whenever i am close to a wall it get's to 1 as it should, but Cam_x and Cam_z don't get constrained to the values they had before the collision occured and i simply pass through the wall. I must be doing something wrong, but i can't figure out what. Any ideas/help would be appreciated. I tried using the 3D entity system for collision checking. I created a sphere and placed it to where the camera is. I am doing an EntityCollisionSlide(ball, 0, Cam_x, Cam_y, Cam_z) and then Cam_z = z_old  and   Cam_x = x_old, but still to no avail. The camera, keeps passing through the walls.

Pages: [1]