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
1 registered members (TipmyPip), 18,038 guests, and 6 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
c_trace + camera.z #370375
05/12/11 18:42
05/12/11 18:42
Joined: Dec 2010
Posts: 87
R
romin2011 Offline OP
Junior Member
romin2011  Offline OP
Junior Member
R

Joined: Dec 2010
Posts: 87
Hello,
I am confused with a situation i encountered.
First take a look at the 3rd person camera code...

Code:
function handle_camera() {
	var temp;
	var cam_center=55;
	var camera_distance=150;

	camera.pan -= mouse_force.x * 12 * time_step;
	camera.tilt += mouse_force.y * 8 * time_step;
	camera.tilt = clamp(camera.tilt,-45,45);
	temp = fcos(camera.tilt,-camera_distance);
	vec_set(camera.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + cam_center + fsin(camera.tilt,-camera_distance)));
	VECTOR temp;
	vec_diff(temp.x,camera.x,my.x); //find the vector from the player to the camera
	vec_normalize(temp.x,16); //get the magnitude of it's vector to 16 quants and store it in temp
	vec_add(temp.x,camera.x); //add the vector (from player to camera) of a magnitude of 16 quants and add it to the camera's position.
	
	result = c_trace(vector(my.x,my.y,my.z+cam_center),temp.x,IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS); //trace from the player to 16 quants behind the camera.
	if (result > 0) {
		vec_diff(temp.x,my.x,target.x); //find the vector from the point the trace hit to the player
		vec_normalize(temp.x,16); //get the magnitude of this vector to 16 quants and store in temp
		vec_set(camera.x,target.x); //place the camera at the trace hit point
		vec_add(camera.x,temp.x); //move the camera away from the wall by the vector temp, 16 quants towards the player
	}
}



The camera is standing behind the player and it is tracing 16 quants behind camera for obstacles and gets closer to player as the camera colides with obstacles.

Let's say camera colides with the wall and the c_trace returns result 140. Now as the camera gets closer to the wall the result keep decreasing.
Now what i want is as the result keeps decreasing i want to keep the camera.z increasing and vice versa.
Ihope you understand what i mean.
Thanx

Re: c_trace + camera.z [Re: romin2011] #370377
05/12/11 19:16
05/12/11 19:16
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Place
Code:
camera.z -= result * 0.1;


after "vec_add(camera.x,temp.x);". Does that do the trick fo you?


Always learn from history, to be sure you make the same mistakes again...
Re: c_trace + camera.z [Re: Uhrwerk] #370382
05/12/11 20:07
05/12/11 20:07
Joined: Dec 2010
Posts: 87
R
romin2011 Offline OP
Junior Member
romin2011  Offline OP
Junior Member
R

Joined: Dec 2010
Posts: 87
No it decreases the height instead of increasing. And if i put += upon collision the camera suddenly get high due to result variable and keep decreasing as result keeps decreasing and i want the other way.


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

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