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,570 guests, and 5 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
Tank Cam #353191
01/08/11 11:11
01/08/11 11:11
Joined: Feb 2007
Posts: 146
UK
robertbruce Offline OP
Member
robertbruce  Offline OP
Member

Joined: Feb 2007
Posts: 146
UK
Hello,

I'm making a simple tank game using the Aum 12 template and having difficulty with the camera collision.

While there are many scripts out there that deal with this I cannot seem to extract the code and
add to my project. I've tried KOH and others.

I would like a simple camera that stays behind the player and zooms in if the view is obscured by a
block or model eg building. That's it really.

Just wondered if someone had a simple collision code for cameras that will zoom towards the player
if this happens.

My code is below but shakes and does not zoom in when the camera is blocked by models.








FUNCTION handle_3rd_camera() {

camera_tilt = clamp(camera_tilt,-30,10);
camera.z=my.z+180;


temp = fcos(camera_tilt,-camera_distance);
vec_set(camera_move_to.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + 20 + fsin(camera_tilt,-camera_distance)));
temp = min(1,0.5 * time); //changing 0.5 will change how fast the camera moves, at 1 places us at target, this value is what allows the smooth movement

camera.x += temp*(camera_move_to.x - camera.x);
camera.y += temp*(camera_move_to.y - camera.y);
camera.z += temp*(camera_move_to.z - camera.z);

vec_diff(temp.x,camera.x,my.x);
vec_normalize(temp.x,16);
vec_add(temp.x,camera.x);

c_trace(my.x,temp.x,ignore_me|ignore_passable);
IF (result > 0) {
vec_diff(temp.x,my.x,target.x);
vec_normalize(temp.x,16);
vec_set(camera.x,target.x);
vec_add(camera.x,temp.x);
}

}



action player_tank
{
my.scale_x=0.75;
my.scale_y=0.75;
my.scale_z=0.75;
player = me;
my.enable_impact = on;
my.enable_entity = on;
my.event = tank_damaged;
my.passable=off;
my.polygon=on;

ent_create(challenger_turret, nullvector, attach_player_turret);
ent_create(challenger_barrel, nullvector, attach_player_barrel);

my.shield = 250; // 250 shield points for player's tank

while (my.shield > 0) // the 10th hit will destroy player's tank
{
handle_camera();
//movement code here
}



thanks,



Rob

Re: Tank Cam [Re: robertbruce] #353660
01/12/11 05:04
01/12/11 05:04
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
Here's a very simple camera code that may help.
Code:
function camera_code() // call this from within that while loop in your player function
{
		temp[0] = c_trace(my.x,camera.x,IGNORE_ME+IGNORE_PASSABLE);
		if(temp[0] != 0) { cam_dist[0] = maxv(-125,-1*temp[0]); } else {	cam_dist[0] = -125; }
		cam_dist[1] = 0;
		cam_dist[2] = 0;
		vec_set(camera.x, my.x);
		vec_rotate(cam_dist, my.pan);
		vec_add(camera.x, cam_dist);
}



It's Lite-C technically but it should work in C-Script, if it doesn't let me know and I'll take a look.

Just replace your camera code with that.

cam_dist[0...3] should be set to how far back you want the camera behind the player.

E.g.
cam_dist[0] = -125; // -125 units behind the player if it can
cam_dist[1] = 0; // to the side, I suppose
cam_dist[2] = 15; // 15 above default level

Last edited by Logan; 01/12/11 05:07.
Re: Tank Cam [Re: Logan] #354459
01/18/11 22:06
01/18/11 22:06
Joined: Feb 2007
Posts: 146
UK
robertbruce Offline OP
Member
robertbruce  Offline OP
Member

Joined: Feb 2007
Posts: 146
UK
Thanks for the code.

I managed to implement a 3 set movement system using a hybrid of 3 movement codes.


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