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
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 16,655 guests, and 7 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
Page 2 of 2 1 2
Re: smooth camera script [Re: Marwan] #157952
10/02/07 12:44
10/02/07 12:44
Joined: Nov 2004
Posts: 862
Australia
DavidLancaster Offline
User
DavidLancaster  Offline
User

Joined: Nov 2004
Posts: 862
Australia
Well if you called that function each frame, the camera's movement will increase by a certain number each frame, say this number is 1. So if the frame rate is 30 frames per second the camera will move 30 quants each second, if the frame rate is at 5 frames per second the camera will move at 5 quants each second, see the problem? The camera would be moving too slow at 5 quants per second. You want it to move at 30 quants per second no matter what. The solution is to multiply the variable by time_step as this would offset the value to make the camera move at 30 quants per second no matter what the frame rate, see the variable in the manual.

What you have effectively managed to achieve, I think, is by dividing the difference in the camera position by 10, making it move smoothly:

This camera code from the Kingdom Hearts tutorial is doing the same thing, if the frame rate is too low temp will be equal to 1 meaning that the camera will be set instantly to it's position, if the camera is running at a good speed temp will be around 0.5 (which is really what your /10 is doing)
Code:

temp = min(1,0.5 * time_step); //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);


Code:

/*FUNCTION handle_camera() {
camera_pan -= mouse_force.x * 12 * time_step;
camera_tilt += mouse_force.y * 8 * time_step;
camera_tilt = clamp(camera_tilt,-30,10);

camera.pan = camera_pan;
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_step); //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);

trace_mode = ignore_me + ignore_passable + ignore_models + ignore_sprites;
IF (trace(my.x,temp.x) > 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);
}

vec_diff(temp.x,my.x,camera.x);
vec_to_angle(camera.pan,temp.x);
}*/



Re: smooth camera script [Re: DavidLancaster] #157953
10/02/07 12:54
10/02/07 12:54
Joined: Aug 2006
Posts: 152
vector(200,45,338)
Marwan Offline OP
Member
Marwan  Offline OP
Member

Joined: Aug 2006
Posts: 152
vector(200,45,338)
Good explanation , Thanks for your efforts


age:16 game design and programming experience:2 years
Re: smooth camera script [Re: Marwan] #157954
10/08/07 11:40
10/08/07 11:40
Joined: Sep 2007
Posts: 658
germany
Tiles Offline
User
Tiles  Offline
User

Joined: Sep 2007
Posts: 658
germany
Cannot get it to work with Lite C due lack of knowledge. How should the code look for Lite C?


trueSpace 7.6, A7 commercial
Free gamegraphics, freewaregames http://www.reinerstilesets.de
Die Community rund um Spiele-Toolkits http://www.clickzone.de
Re: smooth camera script [Re: Tiles] #157955
10/09/07 09:04
10/09/07 09:04
Joined: Aug 2006
Posts: 152
vector(200,45,338)
Marwan Offline OP
Member
Marwan  Offline OP
Member

Joined: Aug 2006
Posts: 152
vector(200,45,338)
read the section of (from c-script to lite-c) in the A7 manual


age:16 game design and programming experience:2 years
Re: smooth camera script [Re: Marwan] #157956
10/09/07 09:27
10/09/07 09:27
Joined: Sep 2007
Posts: 658
germany
Tiles Offline
User
Tiles  Offline
User

Joined: Sep 2007
Posts: 658
germany
That is exactly the part where i am lost. I've been there before. It's the same section where i cannot get any info about why it isn't working


trueSpace 7.6, A7 commercial
Free gamegraphics, freewaregames http://www.reinerstilesets.de
Die Community rund um Spiele-Toolkits http://www.clickzone.de
Re: smooth camera script [Re: Tiles] #157957
10/09/07 13:48
10/09/07 13:48
Joined: Aug 2006
Posts: 152
vector(200,45,338)
Marwan Offline OP
Member
Marwan  Offline OP
Member

Joined: Aug 2006
Posts: 152
vector(200,45,338)
sorry , but I cant help you , I dont have experience with lite-c
but I will give you a tip

make sure you put the function in a while loop like this

action the_player
{
while(1)
{
smooth_camera();
wait(1);
}
}


age:16 game design and programming experience:2 years
Re: smooth camera script [Re: Marwan] #157958
10/09/07 16:45
10/09/07 16:45
Joined: Sep 2007
Posts: 658
germany
Tiles Offline
User
Tiles  Offline
User

Joined: Sep 2007
Posts: 658
germany
Okay. Doesn't help me at all. Seems that i need a few more lotta experience before i can understand this one. But nevertheless. Thank you


trueSpace 7.6, A7 commercial
Free gamegraphics, freewaregames http://www.reinerstilesets.de
Die Community rund um Spiele-Toolkits http://www.clickzone.de
Re: smooth camera script [Re: Tiles] #157959
10/10/07 16:08
10/10/07 16:08
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
min() must be changed to minv() in order to make it work with Lite-C.

trace(my.x,temp.x) must be replaced by c_trace (my.x, temp.x, IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS|IGNORE_SPRITES);

Last edited by Firoball; 10/10/07 16:11.
Re: smooth camera script [Re: FBL] #157960
10/10/07 16:45
10/10/07 16:45
Joined: Sep 2007
Posts: 658
germany
Tiles Offline
User
Tiles  Offline
User

Joined: Sep 2007
Posts: 658
germany
Many thanks for that. Have solved it another way now. But i will surely invest into this to understand it


trueSpace 7.6, A7 commercial
Free gamegraphics, freewaregames http://www.reinerstilesets.de
Die Community rund um Spiele-Toolkits http://www.clickzone.de
Page 2 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

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