Gamestudio Links
Zorro Links
Newest Posts
blogherenowcenter
by 3s05bmmc. 06/05/24 06:08
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,377 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19057 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 | 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