Posted By: jaknine
Need help tweaking this old camera code for A7 - 05/26/09 08:04
Can anyone add the few things needed to make this older C-script code work with A7? It's code I used for a cut camera system on an old game and it worked great for it. I'm trying to use it in a new project but it keeps throwing up errors because of some deprecated commands. I have a feeling it's a fairly simple thing to change it but I've tried a bunch of things and for some reason I just can't get it to work in A7.
Basically the code does this...
There's a dummy object that serves as the camera, and it always faces towards a center point. There are several paths in the level and when a key is pressed the camera jumps to the given path and travels around it.
The buggy stuff happens where it determines the waypoints. All that path stuff has changed over the years and this old way of doing it doesn't work anymore.
So, any help making this work in A7 would be appreciated, and I am happy to pay for a fix if someone can get it working within a day or two.
Thanks!
Basically the code does this...
There's a dummy object that serves as the camera, and it always faces towards a center point. There are several paths in the level and when a key is pressed the camera jumps to the given path and travels around it.
The buggy stuff happens where it determines the waypoints. All that path stuff has changed over the years and this old way of doing it doesn't work anymore.
So, any help making this work in A7 would be appreciated, and I am happy to pay for a fix if someone can get it working within a day or two.
Thanks!
Code:
// don't forget to "include" this file // attach action cutcamera_init to an entity view cutcamera{} var cut_center; var max_speed = 4; var counter = 99; var timeslow = 0; ///////////////////////////////////////////////////////////////////////////////////////////////////////////// action cutcamera_init // attach it to dummy.mdl, etc. { clip_size = 0; // render all the triangles for all the models vec_set (cut_center, my.pos); // store the (relative) center values my.skill20 = max_speed; // store the speed my.invisible = on; my.passable = on; camera.visible = off; // disable "camera" view cutcamera.tilt = -5; // look down a bit cutcamera.pos_x = 0; cutcamera.pos_y = 0; cutcamera.size_x = screen_size.x; cutcamera.size_y = screen_size.y; ent_path("pathfly"); // follow this path ent_waypoint(my._target_x, 1); // store first waypoint my.x = my._target_x; // start from the first waypoint my.y = my._target_y; my.z = my._target_z; wait(4); cutcamera.visible = on; // make cutcamera visible while(1) { cutcamera.x = my.x; cutcamera.y = my.y; cutcamera.z = my.z; cutcamera.pan = my.pan; // follow path -> set _speed vec_set(my._speed, my._target_x); vec_sub(my._speed, my.x); // don't get too close to the target -> find next waypoint if (vec_to_angle(my.pan, my._speed) < 15) { ent_nextpoint(my._target_x); } // turn the camera towards its center (cut_center) vec_set (temp, cut_center.x); vec_sub (temp, my.x); vec_to_angle (my.pan, temp); vec_normalize(my._speed, (max_speed * time)); // normalize _speed /////////////////////// KEYS //////////////////////// if (key_s != 1) // press "S" to stop the movement { ent_move(nullskill, my._speed); } if (key_1 == 1) // press "1" to freeze the current view { cutcamera.x = my.x; cutcamera.y = my.y; cutcamera.z = my.z; cutcamera.pan = my.pan; ent_move(nullskill, my._speed); max_speed = 0; my.skill20 = max_speed; // store the speed } if (key_2 == 1) // press "2" { camera.visible = off; // disable "camera" view cutcamera.visible = on; // make cutcamera visible ent_path("campathround"); // follow this path cutcamera.tilt = -14; // look down a bit max_speed = 6; my.skill20 = max_speed; // store the speed } if (key_3 == 1) // press "3" { camera.visible = off; // disable "camera" view cutcamera.visible = on; // make cutcamera visible ent_path("pathfly"); // follow this path cutcamera.tilt = -5; // look down a bit max_speed = 4; my.skill20 = max_speed; // store the speed } if (key_4 == 1) // press "4" { camera.visible = off; // disable "camera" view cutcamera.visible = on; // make cutcamera visible ent_path("campathroundbig"); // follow this path cutcamera.tilt = -10; // look down a bit max_speed = 7; my.skill20 = max_speed; // store the speed } if (key_5 == 1) // press "5" { camera.visible = off; // disable "camera" view cutcamera.visible = on; // make cutcamera visible ent_path("campathwide"); // follow this path cutcamera.tilt = -2; max_speed = 7; my.skill20 = max_speed; // store the speed } if (key_6 == 1) // press "6" { camera.visible = off; // disable "camera" view cutcamera.visible = on; // make cutcamera visible ent_path("upperpath"); // follow this path cutcamera.tilt = -12; max_speed = 3; my.skill20 = max_speed; // store the speed } if (key_7 == 1) // press "7" { camera.visible = off; // disable "camera" view cutcamera.visible = on; // make cutcamera visible ent_path("campath1"); // follow this path cutcamera.tilt = -10; // look down a bit max_speed = 3; my.skill20 = max_speed; // store the speed } if (key_8 == 1) // press "8" { camera.visible = off; // disable "camera" view cutcamera.visible = on; // make cutcamera visible ent_path("highcam"); // follow this path cutcamera.tilt = -30; // look down a bit max_speed = 5; my.skill20 = max_speed; // store the speed } if (key_9 == 1) // press "9" { camera.visible = off; // disable "camera" view cutcamera.visible = on; // make cutcamera visible ent_path("undercam"); // follow this path cutcamera.tilt = 30; // look down a bit max_speed = 5; my.skill20 = max_speed; // store the speed } if (key_a == 1) // press "a" to turn on regular "free" camera { camera.visible = on; // enable "camera" view cutcamera.visible = off; // make cutcamera invisible } // add some spices if (my.z < 190) // get this value in wed { max_speed = max (my.skill20 / 2, max_speed * 0.995); } else { max_speed = min (my.skill20, max_speed * 1.005); } wait(1); } }