Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (vicknick, AndrewAMD), 1,292 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 4
Page 6 of 7 1 2 3 4 5 6 7
Avoidance Camera [Re: molotov] #86329
12/26/06 03:09
12/26/06 03:09
Joined: Nov 2004
Posts: 862
Australia
DavidLancaster Offline OP
User
DavidLancaster  Offline OP
User

Joined: Nov 2004
Posts: 862
Australia
This only works well in some situations, it's an alright start to a brilliant concept. Make your KH script so that the camera rotates when you move:

Code:

IF (key_w == 1 && key_s == 0 && key_a == 0 && key_d == 0) { temp.x = camera.pan; }
IF (key_s == 1 && key_w == 0 && key_a == 0 && key_d == 0) { temp.x = camera.pan + 180; }
IF (key_a == 1 && key_s == 0 && key_w == 0 && key_d == 0) { temp.x = camera.pan + 90; camera.pan += 5 * time; }
IF (key_d == 1 && key_s == 0 && key_a == 0 && key_w == 0) { temp.x = camera.pan - 90; camera.pan -= 5 * time; }
IF (key_w == 1 && key_a == 1 && key_d == 0 && key_s == 0) { temp.x = camera.pan + 45; camera.pan += 2.5 * time; }
IF (key_w == 1 && key_d == 1 && key_a == 0 && key_s == 0) { temp.x = camera.pan - 45; camera.pan -= 2.5 * time; }
IF (key_s == 1 && key_a == 1 && key_d == 0 && key_w == 0) { temp.x = camera.pan + 135; camera.pan += 6 * time; }
IF (key_s == 1 && key_d == 1 && key_a == 0 && key_w == 0) { temp.x = camera.pan - 135; camera.pan -= 6 * time; }



Now add the following code at the beginning of handle_camera. You will need to define the variable result2 or use a different variable.

Code:

result2 = 0; //trace 30 degrees to both sides of the camera and determine if it should move closer to the player
vec_diff(temp.x,camera.x,my.x);
vec_to_angle(temp2.pan,temp.x);

temp2.pan += 45; //45 degrees
vec_set(temp.x,vector(my.x + fcos(temp2.pan,camera_distance),my.y + fsin(temp2.pan,camera_distance),camera.z));
c_trace(my.x,temp.x,ignore_me|ignore_passable|ignore_models);
IF (result > 0) { result2 -= (camera_distance - result)/camera_distance; }

temp2.pan -= 90; //-45 degrees
vec_set(temp.x,vector(my.x + fcos(temp2.pan,camera_distance),my.y + fsin(temp2.pan,camera_distance),camera.z));
c_trace(my.x,temp.x,ignore_me|ignore_passable|ignore_models);
IF (result > 0) { result2 += (camera_distance - result)/camera_distance; }


temp2.pan += 75; //30 degrees
vec_set(temp.x,vector(my.x + fcos(temp2.pan,camera_distance),my.y + fsin(temp2.pan,camera_distance),camera.z));
c_trace(my.x,temp.x,ignore_me|ignore_passable|ignore_models);
IF (result > 0) { result2 -= ((camera_distance - result)/camera_distance) * 2; }

temp2.pan -= 60; //-30 degrees
vec_set(temp.x,vector(my.x + fcos(temp2.pan,camera_distance),my.y + fsin(temp2.pan,camera_distance),camera.z));
c_trace(my.x,temp.x,ignore_me|ignore_passable|ignore_models);
IF (result > 0) { result2 += ((camera_distance - result)/camera_distance) * 2; }


temp2.pan += 45; //15 degrees
vec_set(temp.x,vector(my.x + fcos(temp2.pan,camera_distance),my.y + fsin(temp2.pan,camera_distance),camera.z));
c_trace(my.x,temp.x,ignore_me|ignore_passable|ignore_models);
IF (result > 0) { result2 -= ((camera_distance - result)/camera_distance) * 10; }

temp2.pan -= 30; //-15 degrees
vec_set(temp.x,vector(my.x + fcos(temp2.pan,camera_distance),my.y + fsin(temp2.pan,camera_distance),camera.z));
c_trace(my.x,temp.x,ignore_me|ignore_passable|ignore_models);
IF (result > 0) { result2 += ((camera_distance - result)/camera_distance) * 10; }

camera.pan += result2 * 0.2;



Now the camera will pan based on obstacles around it, in a sense it's as though the camera moves to gt a better angle. It works really well in some cases and not so well in others. It will work well if the level design suits it, should require some tweaking but there's some code for a start. Based on this cool gamasutra article:

http://www.gamasutra.com/gdc2004/features/20040325/giors_02.shtml

Orange Brat posted here:

http://www.coniserver.net/ubbthreads/sho...true#Post681972

Re: Avoidance Camera [Re: DavidLancaster] #86330
12/26/06 03:14
12/26/06 03:14
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline

Senior Expert
Orange Brat  Offline

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Yeah, I think that system is more like the Max Payne style camera system. However, your Kingdom Hearts code takes care of the wall clipping issue nicely. I've never seen another publically available one do it (templates included), so it's the ultimate one; thus everyone should at least use the wall collision code if they want a pro style camera. Anyway, I'll test out this implementation later one. Thanks for your continued camera contribs.


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: Avoidance Camera [Re: Orange Brat] #86331
12/26/06 05:14
12/26/06 05:14
Joined: Nov 2004
Posts: 862
Australia
DavidLancaster Offline OP
User
DavidLancaster  Offline OP
User

Joined: Nov 2004
Posts: 862
Australia
Also with that code above, it seems to work best if you only activate it if the player is moving, that way if you stand idle next to a wall the camera wont move as you try and line it up for a jump etc.

You're very welcome Orange Brat

Your information and input on these forums is much appreciated and helped me lots. Your adventure thread is very interesting and informative.

Re: Avoidance Camera [Re: DavidLancaster] #86332
01/29/07 13:36
01/29/07 13:36
Joined: Apr 2006
Posts: 329
M
molotov Offline
Senior Member
molotov  Offline
Senior Member
M

Joined: Apr 2006
Posts: 329
Hey DavidLancaster, when I use your camera from the kingdom Hearts Tutorial, and walk up some stairs, the camera starts to shock a bit. Do you have a solution to fix this? Thanks anyway.

Re: Avoidance Camera [Re: molotov] #86333
02/02/07 13:32
02/02/07 13:32
Joined: Nov 2004
Posts: 862
Australia
DavidLancaster Offline OP
User
DavidLancaster  Offline OP
User

Joined: Nov 2004
Posts: 862
Australia
The only reason I can think why the camera would shake is because of the way the player is moving up the stairs (ie it's not moving smoothly)...other than that it shouldn't shake, I think, unless you can give me more details.

Re: Avoidance Camera [Re: DavidLancaster] #86334
02/02/07 14:51
02/02/07 14:51
Joined: Apr 2006
Posts: 329
M
molotov Offline
Senior Member
molotov  Offline
Senior Member
M

Joined: Apr 2006
Posts: 329
Hey DavidLancaster, the camera is shaking when I move up the stairs but not when I go down the stairs. The movement is running smoothly/perfectly. Also the camera is working great except when I'm moving up a stairway. The stairs is just made of blocks. Don't know how to give more details.

Re: Avoidance Camera [Re: molotov] #86335
02/04/07 03:11
02/04/07 03:11
Joined: Nov 2004
Posts: 862
Australia
DavidLancaster Offline OP
User
DavidLancaster  Offline OP
User

Joined: Nov 2004
Posts: 862
Australia
This demo has stairs:

http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/707960/an/0/page/1#Post707960

Camera doesn't shake when running up those...could be the way they are designed though..

Re: Avoidance Camera [Re: DavidLancaster] #86336
02/04/07 13:29
02/04/07 13:29
Joined: Apr 2006
Posts: 329
M
molotov Offline
Senior Member
molotov  Offline
Senior Member
M

Joined: Apr 2006
Posts: 329
Hey DavidLancaster, I found out it was the way my stairs were designed. My stairs used too large parts. Thanks for your help.

Re: Avoidance Camera [Re: molotov] #86337
02/04/07 13:48
02/04/07 13:48
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
David, this is a great tutorial, i'll be implementing this into PreVa


- aka Manslayer101
Re: Avoidance Camera [Re: mpdeveloper_B] #86338
02/04/07 23:38
02/04/07 23:38
Joined: Nov 2004
Posts: 862
Australia
DavidLancaster Offline OP
User
DavidLancaster  Offline OP
User

Joined: Nov 2004
Posts: 862
Australia
PreVa rocks, I liked the dodging movement Fun game

Page 6 of 7 1 2 3 4 5 6 7

Moderated by  adoado, checkbutton, mk_1, Perro 

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