2 registered members (OptimusPrime, AndrewAMD),
14,580
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
make a camera follow from 3rd person
#238949
12/01/08 11:58
12/01/08 11:58
|
Joined: Oct 2008
Posts: 67
pewpew
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2008
Posts: 67
|
Hey I am just trying to make a camera follow a player's tank from 3rd person but cant seem to get it to work correctly. the tank moves fine, and rotates fine, but the camera stays in one position directly behind the tank. what i am trying to say is, the camera does not rotate around the tank. Here is the code i am using:
action move_tank()
{
camera.tilt = -30;
while(1)
{
if(key_pressed(17) == 1)
c_move(me, vector(0, -5 * time_step, 0), nullvector, GLIDE);
if(key_pressed(30) == 1)
me.pan += 2 * time_step;
//c_rotate(me, 4, IGNORE_MODELS);
if(key_pressed(31) == 1)
c_move(me, vector(0, 5 * time_step, 0), nullvector, GLIDE);
if(key_pressed(32) == 1)
me.pan -= 2 * time_step;
camera.x = me.x + cx;
camera.y = me.y + cy;
camera.z = me.z + cz;
wait(1);
}
}
any help would be gladly appreciated 
HURRR DERP DERP DEERRPP HURR
|
|
|
Re: make a camera follow from 3rd person
[Re: pewpew]
#238952
12/01/08 12:31
12/01/08 12:31
|
Joined: Oct 2007
Posts: 5,211 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
here is a simple 3rd person camera.
action Thirdp(){
var camdist = 200; //camera distance
camera.tilt = -45;
while(1){
camera.pan = my.pan;
camera.x = my.x-camdist*cosv(camera.pan);
camera.y = my.y-camdist*sinv(camera.pan);
my.pan -= 10*time_step*mouse_force.x;
camera.z = my.z+camdist;
wait(1);
}
}
3333333333
|
|
|
Re: make a camera follow from 3rd person
[Re: pewpew]
#239048
12/02/08 06:54
12/02/08 06:54
|
Joined: Oct 2007
Posts: 5,211 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
your tank is not looking at x direction.  if you dont want to change your model. change the camera.pan = my.pan; to camera.pan = my.pan-90; (or maybe +90)
3333333333
|
|
|
Re: make a camera follow from 3rd person
[Re: Quad]
#239084
12/02/08 13:15
12/02/08 13:15
|
Joined: Nov 2008
Posts: 25
MrTwiggy101
Newbie
|
Newbie
Joined: Nov 2008
Posts: 25
|
Do you have another code that works? I am trying to use that Thirdp code but it always just crashes my thing when I try to run. It works fine, but, it doesn't stay behind the model, it just sits at the same angle and turns. This is what I have. //////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////
//ENTITY* car;
var walk_percentage;
action my_car()
{
while (1)
{
if (key_cul)
{
my.pan += 3*time_step; // increase the pan angle of the car
camera.pan += 3*time_step;
}
// does same thing as above but is faster
if (key_cur)
{
my.pan -= 3*time_step;
camera.pan -= 3*time_step;
// decrease the pan angle of the car
}
if (key_cuu) // press and hold the "Space" key to move the car
{
c_move (my, vector(15*time_step, 0, 0), nullvector, GLIDE);
}
if (key_cud)
{
c_move (my, vector(-15*time_step, 0, 0), nullvector, GLIDE);
}
if (key_d)
{
c_move (my, vector(0, 0, -5), nullvector, GLIDE);
}
camera.x = my.x-100;
camera.y = my.y;
camera.z = my.z+50;
camera.tilt = -20;
wait(1);
}
}
function main()
{
level_load ("homework18.wmb");
wait (2);
//car = ent_create("car1.mdl", vector(0,0,10), NULL);
ent_create("guard.mdl", vector(400,0,100), my_car);
//camera.x = car.x;
//camera.y = car.y;
//camera.z = car.z +17;
//camera.tilt = -5;
wait(1);
}
|
|
|
Re: make a camera follow from 3rd person
[Re: Hitsch]
#239316
12/03/08 22:44
12/03/08 22:44
|
Joined: Oct 2008
Posts: 67
pewpew
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2008
Posts: 67
|
Once again Quad, you hit the nail on the head. The models were not aligned to the correct axis from the mdl file itself. I rotated them and its all good now. Thanks mate  Now to get the physics problems sorted lol
HURRR DERP DERP DEERRPP HURR
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|