Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Camera rotation [Re: tompo] #123218
04/12/07 11:56
04/12/07 11:56
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
I've forgot asisr parameter:)
Now it's work! But... what about the camera?!
Always behind the ship, looking at it? whith the same pan,tilt,roll as player?


Never say never.
Re: Camera rotation [Re: tompo] #123219
04/12/07 12:18
04/12/07 12:18
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Take a look at "ang_add" and "ang_rotate" in the manual.
There is an example code, which I'll just copy and paste here:
Code:

// A camera is hunting a target and turns with them, keeping the target always in the middle of the view.
var cam_dist[3] = -500,100,100; // xyz distance vector from camera towards the target

function chase_camera(target)
{
my = target; // The target Entity
// calculate the camera view's direction angle to the target
var cam_ang[3]; // direction angle of the camera to the target.
vec_diff(temp,nullvector,cam_dist);
vec_to_angle(cam_ang,temp);
cam_ang.roll = 0; // roll didn't change vec_to_angle

// permanent updating of the camera's position and angle
while (1)
{
// place the camera at the right position to the target
vec_set(camera.x,cam_dist);
vec_rotate(camera.x,my.pan);
vec_add(camera.x,my.x);
// Set the camera angles to the camera view direction
vec_set(camera.pan,cam_ang);
// and rotate it about the target angle
ang_add(camera.pan,my.pan);
wait(1);
}
}



Re: Camera rotation [Re: Xarthor] #123220
04/12/07 14:49
04/12/07 14:49
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
Yes... You right... but it look ugly...
I mean... to add a little delay to player move.
First move camera and then with little delay the ship. So if you f.e. turn left, first camera move left, and ship is on the right side of the screen:) Turn up - ship is on the bottom... etc:)
But thanks a lot anyway.


Never say never.
Re: Camera rotation [Re: tompo] #123221
04/12/07 15:18
04/12/07 15:18
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
For camera lag, you may try this and modify it
a little bit to fit your needs :

Code:

var speed = 0.1; // play with it
var temp2[3];
var camera_dist[3] = 25,0,-6; // play with it
action spaceShip
{
while(my!=NULL)
{
//.....
c_rotate(.....,USE_AXISR);

vec_set(temp,camera_dist);
vec_rotate(temp,camera.pan);

vec_add(temp,my.x);
vec_set(camera.pan,my.pan);

vec_set(temp2,temp);
vec_sub(temp2,camera.x);
vec_scale(temp2,speed2*time_step);
vec_add(camera.x,temp2);

wait(1)
}
}



And Thunder's example is my favourite camera codes, I always
use it in my game.

Good luck!

Last edited by vlau; 04/12/07 15:19.
Re: Camera rotation [Re: vlau] #123222
04/12/07 15:46
04/12/07 15:46
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
Now my code looks like this:

define ship_speed, skill1;
var mouse_hor;
var mouse_ver;
var speed = 0.1;
var temp2[3];
var camera_dist[3] = -25,0,6; (behind & little up)

while(1)
{
mouse_hor = (pointer.x - ((screen_size.x )/2)) *-0.01;
mouse_ver = (pointer.y - ((screen_size.y )/2)) *-0.01;
c_rotate (me, vector(mouse_hor *time_step,mouse_ver *time_step,0), USE_AXISR);
c_move(me,vector(my.ship_speed *time_step,0,0),nullvector,GLIDE | ACTIVATE_TRIGGER | IGNORE_SPRITES | IGNORE_PASSENTS);

vec_set(camera.x,camera_dist);
vec_rotate(camera.x,my.pan);
vec_add(camera.x,my.x);
vec_set(temp,camera_dist);
vec_rotate(temp,camera.pan);

vec_add(temp,my.x);
vec_set(camera.pan,my.pan);
vec_set(temp2,temp);
vec_sub(temp2,camera.x);
vec_scale(temp2,speed*time_step);
vec_add(camera.x,temp2);
wait(1);
}

and.... no delay it means... ship is always in the same position of the screen;)


Never say never.
Re: Camera rotation [Re: tompo] #123223
04/12/07 16:05
04/12/07 16:05
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
OK
I've forgotten to cut:

vec_set(camera.x,camera_dist);
vec_rotate(camera.x,my.pan);
vec_add(camera.x,my.x);

:):)


Never say never.
Page 2 of 2 1 2

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