Gamestudio Links
Zorro Links
Newest Posts
Purchase A8 full licence version
by ukgamer. 04/29/26 18:09
Z9 getting Error 058
by k_ivan. 04/25/26 19:13
ZorroGPT
by TipmyPip. 04/25/26 16:09
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 5,733 guests, and 39 spiders.
Key: Admin, Global Mod, Mod
Newest Members
ukgamer, valino, juergenwue, VladMak, Geir
19210 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 | 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