Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (VoroneTZ, 7th_zorro), 1,071 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
chase camera help #270414
06/08/09 08:24
06/08/09 08:24
Joined: Mar 2009
Posts: 276
Cebu City, Philippines
boyax Offline OP
Member
boyax  Offline OP
Member

Joined: Mar 2009
Posts: 276
Cebu City, Philippines
Hi,
What I'm trying to do is adjust camera's position so that:
1. When the spaceship's velocity is constant, the camera tends to occupy certain spot behind the ship; the distance between that spot and the spaceship is constant and does not depend on spaceship's velocity.
2. When the spaceship is accelerating, the camera starts to lag behind
3. When the spaceship is slowing down, the camera closes on the spaceship

Any idea? and How i can make the camera adjustment smooth..?
Hope someone could help.
Thanks

Re: chase camera help [Re: boyax] #270416
06/08/09 08:36
06/08/09 08:36
Joined: Apr 2009
Posts: 298
Southern Oceans
KiwiBoy Offline
Member
KiwiBoy  Offline
Member

Joined: Apr 2009
Posts: 298
Southern Oceans
Normal sin/cos will keep the constant distance Im thinking then modify according to taste.
distance = camera.x, spaceship.x; sort of thing to describe its 'constant'
If(vec_dist(my.x, spaceship.x) > camera_dist.x)
{
or if(spaceship_move > distance) etc...find a way to express accelleration and decelleration...

then modify for the speed differences maybe?
its probably the approach I would take and maybe will soon for follower NPC's.


Use the 'manual' Luke, the manual is your friend. 'Self reminder' smile

My WebPage
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 Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Code:
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 Offline OP
Member
boyax  Offline 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. smile
Code:
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


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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