Can you correct this script

Posted By: mEnTaL

Can you correct this script - 07/01/09 12:25

I'm trying to make FPS camera. The code works, but there are 2 annoying bugs in it:
1) The camera constantly glides over the terrain and can't stop.
2) I can't set tha camera's height in relation to the terrain.

Here is the code:

action free_camera
{
my.invisible = on;

while (1)
{
my.pan -= 10 * mouse_force.x * time_step;
my.tilt += 10 * mouse_force.y * time_step;

c_move(my,vector ((key_w-key_s)*30*time_step,(key_a-key_d)*30*time_step,0),nullvector,GLIDE);

c_move(me,vector(0,0,-10),NULLVECTOR,GLIDE); //my simple code for gravity

vec_set(camera.x, my.x);
vec_set(camera.pan,my.pan);
wait(1);



}
}
Posted By: Joozey

Re: Can you correct this script - 07/01/09 23:14

prevent gliding:
replace: c_move(me,vector(0,0,-10),NULLVECTOR,GLIDE); //my simple code for gravity
by: c_trace(my.z, vector(my.x, my.y, my.z+100), IGNORE_ME | IGNORE_PASSABLE | USE_BOX);
my.z = target.z;

height:
vec_set(camera.x, my.x); //set to ground
camera.z += 50; //add 50 quants upwards


Posted By: mEnTaL

Re: Can you correct this script - 07/02/09 11:08

hmm I tried it, but the camera gets stuck in the terrain and hardly moves.
Posted By: Schmerzmittel

Re: Can you correct this script - 07/02/09 11:20

What Version do you have.

I had the same problem with an older A6 Engine.
Posted By: mEnTaL

Re: Can you correct this script - 07/02/09 12:40

I'm with A7
Posted By: Schmerzmittel

Re: Can you correct this script - 07/02/09 18:02

I mean what versionnumber? Look in SED under About.
Posted By: mEnTaL

Re: Can you correct this script - 07/02/09 19:06

version 7.02.4
© 2023 lite-C Forums