2 registered members (VoroneTZ, 7th_zorro),
1,071
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: chase camera help
[Re: KiwiBoy]
#270449
06/08/09 11:38
06/08/09 11:38
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
var camDist = 100;
var camMaxDist = 200;
var camMinDist = 60;
var camAngle = 15;
VECTOR camGoal;
var camSpeed = .7;
var oldCamPos[3];
while(1)
{
camDist = clamp(camDist + mickey.z*time_step/5,camMinDist,camMaxDist);
vec_set(camGoal,vector(-camDist*cos(camAngle),0,camDist*sin(camAngle)));
vec_rotate(camGoal,vector(ship.pan,ship.tilt,ship.roll));
vec_add(camGoal,ship.x);
vec_diff(temp,camGoal,camera.x);vec_scale(temp,time_step*camSpeed);
vec_add(camera.x,temp);
vec_set(camera.pan,ship.pan);
wait(1);
}
check out this code, it should do exactly what you wanted it to. -No need for trig (it tends to mess up in 3d space games anyways) -easy implementation of shaking cameras -mouse wheel changes distance to ship -hope it helps.
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: chase camera help
[Re: Germanunkol]
#270621
06/09/09 04:14
06/09/09 04:14
|
Joined: Mar 2009
Posts: 276 Cebu City, Philippines
boyax
OP
Member
|
OP
Member
Joined: Mar 2009
Posts: 276
Cebu City, Philippines
|
Thanks Germanunkol. It's useful, I'll try this. By the way, is it ok if you could illustrate the below code for me.
vec_set(camGoal,vector(-camDist*cos(camAngle),0,camDist*sin(camAngle))); vec_rotate(camGoal,vector(player.pan,player.tilt,player.roll));
vec_add(camGoal,player.x);
vec_diff(temp,camGoal,camera.x);
vec_scale(temp,time_step*camSpeed);
vec_add(camera.x,temp);
vec_set(camera.pan,player.pan);
I'm just looking at the manual.. but, still didn't know the theory behind it what you do. Thanks
|
|
|
|