World Of Warcraft Camera

Posted By: OptimuS

World Of Warcraft Camera - 08/26/05 23:22

A little script for a World of Warcraft style camera. I deleted some lines that you dont need , eg. a collision check that does not work right if the script does not work , or give an error , post it because I havent tested it without those lines but I think it should work.
Hope you enjoy it.

Code:

var camera_distance = 400;

var zoom;

function player_act
{
player = me;
zoom = camera_distance;
while(1)
{
if(key_space == 1)
{
if(ang(camera.pan) < ang(player.pan - 3))
{
camera.pan += 5 * time;
}
if(ang(camera.pan) > ang(player.pan + 3))
{
camera.pan -= 5 * time;
}
}

if(mickey.z > 0)
{
zoom -= 25 * time;
}
if(mickey.z < 0)
{
zoom += 25 * time;
}
if(zoom < 40) { zoom = 40; }
if(zoom > 600) { zoom = 600; }

camera_distance = zoom;

if(camera_control == 1)
{
camera.tilt += 6 * mouse_force.y * (time * 2);
if(camera.tilt > 75)
{
camera.tilt = 75;
}
if(camera.tilt < -75)
{
camera.tilt = -75;
}

camera.pan -= 6 * mouse_force.x * (time * 2);
}
else
{
camera.pan += 6 * (key_left - key_right) * time;
}
camera.z = my.z - camera_distance * sin(camera.tilt);
camera.x = my.x - camera_distance * cos(camera.tilt) * cos(camera.pan);
camera.y = my.y - camera_distance * cos(camera.tilt) * sin(camera.pan);
wait(1);
}
}

function camera_control_init()
{
while(1)
{
if(mouse_left == 1)
{
wait(8);
if(mouse_left == 1)
{
camera_control = 1;
}
else
{
camera_control = 0;
}
}
else
{
camera_control = 0;
}
wait(1);
}
}


Posted By: DoC

Re: World Of Warcraft Camera - 08/27/05 18:08

it dont working explain how i must include it and I think many things ar not defined (keyword unknown)
Posted By: Ogtrax

Re: World Of Warcraft Camera - 08/27/05 18:19

Code:
 var camera_distance = 400;

var zoom;

function player_act()
{
player = me;
zoom = camera_distance;
while(1)
{
if(key_space == 1)
{
if(ang(camera.pan) < ang(player.pan - 3))
{
camera.pan += 5 * time;
}
if(ang(camera.pan) > ang(player.pan + 3))
{
camera.pan -= 5 * time;
}
}

if(mickey.z > 0)
{
zoom -= 25 * time;
}
if(mickey.z < 0)
{
zoom += 25 * time;
}
if(zoom < 40) { zoom = 40; }
if(zoom > 600) { zoom = 600; }

camera_distance = zoom;

if(camera_control == 1)
{
camera.tilt += 6 * mouse_force.y * (time * 2);
if(camera.tilt > 75)
{
camera.tilt = 75;
}
if(camera.tilt < -75)
{
camera.tilt = -75;
}

camera.pan -= 6 * mouse_force.x * (time * 2);
}
else
{
camera.pan += 6 * (key_left - key_right) * time;
}
camera.z = my.z - camera_distance * sin(camera.tilt);
camera.x = my.x - camera_distance * cos(camera.tilt) * cos(camera.pan);
camera.y = my.y - camera_distance * cos(camera.tilt) * sin(camera.pan);
wait(1);
}
}

function camera_control_init()
{
while(1)
{
if(mouse_left == 1)
{
wait(8);
if(mouse_left == 1)
{
camera_control = 1;
}
else
{
camera_control = 0;
}
}
else
{
camera_control = 0;
}
wait(1);
}
}



This should work. Just some missing parentheses
Posted By: fogman

Re: World Of Warcraft Camera - 08/27/05 20:10

"camera_control"

I think this is the missing variable. Itīs not
defined.

Define camera_control as global var, then it should work.
Posted By: OptimuS

Re: World Of Warcraft Camera - 08/28/05 20:35

sorry I forgot about that.
The rotation when pressing space isnt working as it should be. Sometimes the camera rotates all around the entity , and the closest way wasnt in this direction...if you can understand what I mean
I will fix this soon , and try to add a collision detection. If someone wants to play with the script and come up with something post it.
© 2024 lite-C Forums