Posted By: joe__p
camera follow - 10/30/14 13:10
I am making a maze game for my class and I am trying to make the camera follow the ball from behind to see better around corners and near walls but I cant get it right. any ideas??
action my_player() { var movement_speed = 10; // movement speed var walk_percentage; var stand_percentage; VECTOR temp; player = my; // I'm the player while (1) { player.pan -= 5 * mouse_force.x * time_step; // rotate the player using the mouse if(!key_w && !key_s) // the player isn't moving at all? { ent_animate(my, "stand", stand_percentage, ANM_CYCLE); // then play its "stand" animation stand_percentage += 5 * time_step; // 5 = animation speed } else // the player is moving? { ent_animate(my, "walk", walk_percentage, ANM_CYCLE); // then play its "walk" animation walk_percentage += 6 * time_step; // 6 = animation speed } camera.x = player.x - 250 * cos(player.pan); camera.y = player.y - 250 * sin(player.pan); camera.pan = player.pan; // the camera and the player have the same pan angle camera.z = player.z + 150; // place the camera above the player, play with this value camera.tilt = -25; temp.x = movement_speed * (key_w - key_s) * time_step; temp.y = movement_speed * (key_a - key_d) * 0.6 * time_step; temp.z = 0; c_move (my, temp.x, nullvector, IGNORE_PASSABLE | GLIDE); wait (1); } }
} camera.x = player.x - 250 * cos(player.pan); camera.y = player.y - 250 * sin(player.pan); camera.pan = player.pan; // the camera and the player have the same pan angle camera.z = player.z + 150; // place the camera above the player, play with this value camera.tilt = -25;