Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (fogman, Grant, AndrewAMD, juanex), 989 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Camera collision with entitys? How? #246350
01/14/09 18:59
01/14/09 18:59
Joined: Aug 2005
Posts: 512
Bayern
Schmerzmittel Offline OP
User
Schmerzmittel  Offline OP
User

Joined: Aug 2005
Posts: 512
Bayern
Hiho @all,

i have a small problem.

I have a camerascript that works well for me. I modified it, but i forgot from what progger it is.

I want to make, that the camera hit something, i.e. a wall or terrain, that the camera moves near the character. I tryed alot, but everything i got is a total cracy rotation.

Here is the script:

Code:
 void control_Camera()
{
	
	if(Hero != 0){wait(1);}
	
	camera.x = Hero->x ;
	camera.y = Hero->y ;
	
	

	while(1)
	{
		if((mouse_right == 1) && (HeroMoves == 0))
		{
		vec_set(V_tempDistance.x, camera.x);
		V_tempDistance.z -= 100;
		v_DistanceTraced = c_trace(Hero->x, V_tempDistance.x, IGNORE_ME | IGNORE_PASSABLE);
		
	
		
			
		camera.z += cam_speed[1] * mouse_force.y * time_step;
		//camera.z = clamp(camera.z, 10, 800);
		
	
		cam_angle += cam_speed[0] * mouse_force.x * time_step;
		cam_angle = ang(cam_angle);
		
		camera.x = Hero->x + cam_radius * sin(cam_angle);
		camera.y = Hero->y + cam_radius * cos(cam_angle);
		
		
		if(v_DistanceTraced >0)
		{
			v_DistanceTraced -= 2;
			camera.x = Hero->x  - v_DistanceTraced * sin(cam_angle);
			camera.y = Hero->y  - v_DistanceTraced * cos(cam_angle);
				vec_to_angle(camera.pan,V_CamVecTemp);
		}
		else
		{
		vec_set(V_CamVecTemp.x,Hero->x);
		vec_sub(V_CamVecTemp.x,camera.x);
		vec_to_angle(camera.pan,V_CamVecTemp);
		}
		
		}
			
			
			
		if((mouse_right == 1) && (HeroMoves == 1))
		{
		camera.z += cam_speed[1] * mouse_force.y * time_step;
		//camera.z = clamp(camera.z, 10, 800);
		
		cam_angle += cam_speed[0] * mouse_force.x * time_step;
		cam_angle = ang(cam_angle);
		
		camera.x = Hero->x + cam_radius * sin(cam_angle);
		camera.y = Hero->y + cam_radius * cos(cam_angle);
		
		vec_set(V_CamVecTemp.x,Hero->x);
		vec_sub(V_CamVecTemp.x,camera.x);
		vec_to_angle(camera.pan,V_CamVecTemp);
		
		Hero.pan = camera.pan;
		}
		
		
		
		if((mouse_right == 0) && (HeroMoves == 0))
		{
	
		//camera.z = clamp(camera.z, 10, 800);
		
		cam_angle = ang(cam_angle);
		
		camera.x = Hero->x + cam_radius * sin(cam_angle);
		camera.y = Hero->y + cam_radius * cos(cam_angle);
		
		vec_set(V_CamVecTemp.x,Hero->x);
		vec_sub(V_CamVecTemp.x,camera.x);
		vec_to_angle(camera.pan,V_CamVecTemp);
		}
		
		
		if((mouse_right == 0) && (HeroMoves == 1))
		{
		
	//	camera.z = clamp(camera.z, 10, 800);
		
		cam_angle = ang(cam_angle);
		
		camera.x = Hero->x + cam_radius * sin(cam_angle);
		camera.y = Hero->y + cam_radius * cos(cam_angle);
		
		vec_set(V_CamVecTemp.x,Hero->x);
		vec_sub(V_CamVecTemp.x,camera.x);
		vec_to_angle(camera.pan,V_CamVecTemp);
		}
	
	
	wait(1);
	}

}


I hope someone can help me, please.

Schmerzmittel


EDIT: One point, that i doesnt know to script is the follow: The camera.z should always at the Hero.z but the camera should not move more than 800 quant above the player and not more than 10 quants below the player. How can i do it? I dont figure it out.

Last edited by Schmerzmittel; 01/14/09 19:01.

A7 Com V7.80
Re: Camera collision with entitys? How? [Re: Schmerzmittel] #246365
01/14/09 20:03
01/14/09 20:03
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Helgehast had almost the same problem. Look here. Hope, it helps. http://www.coniserver.net/ubb7/ubbthreads.php?ubb=showflat&Number=246151#Post246151

For the limitations, add an if-condition that contains the key-instructions.

Something like this:

if(80 < cam_dist < 800)

But I didn't test it.

Re: Camera collision with entitys? How? [Re: Pappenheimer] #246366
01/14/09 20:07
01/14/09 20:07
Joined: Aug 2005
Posts: 512
Bayern
Schmerzmittel Offline OP
User
Schmerzmittel  Offline OP
User

Joined: Aug 2005
Posts: 512
Bayern
Thanks. I will have a look at this.


A7 Com V7.80

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