Camera Collision Detection

Posted By: Wiegje

Camera Collision Detection - 10/08/08 11:29

How do I make it so that the camera stays within the bounds of a hallway and not go to the other side of it?

Thanks
Posted By: qoolelee

Re: Camera Collision Detection - 10/08/08 16:07

Create a small box.mdl, attach the action bellow,
Quote:

action camera_move()
{
var mytemp[3];

while(1)
{
my.pan -= 10 *time_step * mouse_force.x;
my.tilt += 5 * time_step * mouse_force.y;
if(mouse_right || key_w)
{
vec_for_angle(mytemp, my.pan);
vec_scale(mytemp, 10 * time_step);
c_move(me, nullvector, mytemp, GLIDE);
}
if(key_s)
{
vec_for_angle(mytemp, my.pan);
vec_scale(mytemp, -10 * time_step);
c_move(me, nullvector, mytemp, GLIDE);
}
if(key_a)
{
mytemp[0] = cos(my.pan)*cos(my.tilt);
mytemp[1] = sin(my.pan)*cos(my.tilt);
mytemp[2] = 0;
vec_normalize(mytemp, 1);
vec_rotate(mytemp, _vec(90,0,0));
vec_scale(mytemp, 10 * time_step);
c_move(me, nullvector, mytemp, GLIDE);
}
if(key_d)
{
mytemp[0] = cos(my.pan)*cos(my.tilt);
mytemp[1] = sin(my.pan)*cos(my.tilt);
mytemp[2] = 0;
vec_normalize(mytemp, 1);
vec_rotate(mytemp, _vec(-90,0,0));
vec_scale(mytemp, 10 * time_step);
c_move(me, nullvector, mytemp, GLIDE);
}
vec_set(camera.x, my.x);
vec_set(camera.pan, my.pan);


wait(1);
}
}


WASD to move, mouse to pan and tilt.
© 2024 lite-C Forums