Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,731 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
make a camera follow from 3rd person #238949
12/01/08 11:58
12/01/08 11:58
Joined: Oct 2008
Posts: 67
pewpew Offline OP
Junior Member
pewpew  Offline 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:

Code:
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 laugh


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 Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
here is a simple 3rd person camera.

Code:
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: Quad] #239030
12/01/08 23:10
12/01/08 23:10
Joined: Oct 2008
Posts: 67
pewpew Offline OP
Junior Member
pewpew  Offline OP
Junior Member

Joined: Oct 2008
Posts: 67
awesome. Thanks heaps for that Quadraxas laugh
The only thing tho, is the angle. Its tracing the tank from the side >>



HURRR DERP DERP DEERRPP HURR
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 Offline
Senior Expert
Quad  Offline
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
M
MrTwiggy101 Offline
Newbie
MrTwiggy101  Offline
Newbie
M

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.

Code:
//////////////////////////////
#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: MrTwiggy101] #239120
12/02/08 19:23
12/02/08 19:23
Joined: Nov 2008
Posts: 25
M
MrTwiggy101 Offline
Newbie
MrTwiggy101  Offline
Newbie
M

Joined: Nov 2008
Posts: 25
NVM! I just made this one:

camera.x = my.x - 200 * cos(my.pan);
camera.y = my.y - 200 * sin(my.pan);
camera.z = my.z + 100;
camera.pan = my.pan;
camera.tilt = -10;
and added it onto the bottom of my moving action.

Re: make a camera follow from 3rd person [Re: MrTwiggy101] #239216
12/03/08 10:52
12/03/08 10:52
Joined: May 2008
Posts: 150
Switzerland
Hitsch Offline
Member
Hitsch  Offline
Member

Joined: May 2008
Posts: 150
Switzerland
I've also been working on my 3rd person camera that I use to control a hovercraft. Now having a camera simply following every step works fine, but I think it looks a bit strange, because in most games the camera has a delay.
That way it's seems more like the vehicle is turning then the world is turning around the vehicle, and you can see the sides for a bit while moving around.

How would I be able to do that? I tried delaying the position by one time_step, but that's no quit it, to shaky...

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 Offline OP
Junior Member
pewpew  Offline 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 smile
Now to get the physics problems sorted lol


HURRR DERP DERP DEERRPP HURR

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1