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,631 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
camera pan and entity pan #355245
01/25/11 17:51
01/25/11 17:51
Joined: Jan 2011
Posts: 65
R
reknak Offline OP
Junior Member
reknak  Offline OP
Junior Member
R

Joined: Jan 2011
Posts: 65
-edit

problem: third-person cam doesn't move around the entity when rotating.

-edit2 hopfel's perfect solution

Quote:
Code:camera.x=my.x-(50)*cos(my.tilt)*cos(my.pan);
camera.y=my.y-(50)*cos(my.tilt)*sin(my.pan);
camera.z=my.z-(50)*sin(my.tilt);
vec_set(camera.pan,my.pan);


Last edited by reknak; 01/27/11 17:41.
Re: camera pan and entity pan [Re: reknak] #355264
01/25/11 20:05
01/25/11 20:05
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67"...
hopfel Offline
User
hopfel  Offline
User

Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67"...
I think it would be easier, if you set the camera.pan on the player.pan and then just rotate the player with mouse and keys.


Hilf mir, dir zu helfen!
Re: camera pan and entity pan [Re: hopfel] #355269
01/25/11 20:43
01/25/11 20:43
Joined: Dec 2010
Posts: 87
R
romin2011 Offline
Junior Member
romin2011  Offline
Junior Member
R

Joined: Dec 2010
Posts: 87
My.pan += 4 * (key_a - key_d) * time_step - 20 * mouse_force.x * time_step.
It took me longer then ur post to type coz iam using mobile wink

Re: camera pan and entity pan [Re: romin2011] #355276
01/25/11 21:53
01/25/11 21:53
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
You need to be calling vec_rotate WITHIN the while() loop in camera_follow() I think. Right now it's only being called once... you need to call it every time you reset the camera's position.


Try replacing the existing function with this.
Code:
VECTOR* temp_vec=(x=0;y=0;z=0;}
function camera_follow(ENTITY* ent)
{
     vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
     vec_set(camera.pan,vector(ent.pan,-10,0)); // look in player direction, slighty down
     while(1)
     {
          mywizard.pan = camera.pan;
          // you might need to toy with the values in this next line:
          vec_set(temp_vec,vector(50,-100,60)); // camera position relative to the player
          vec_rotate(temp_vec,camera.pan);
          vec_set(camera.x,temp_vec);
          vec_add(camera.x,ent.x); // add player position
          
          wait(1); 
     }

}



Last edited by Logan; 01/25/11 21:54.
Re: camera pan and entity pan [Re: Logan] #355303
01/26/11 10:53
01/26/11 10:53
Joined: Jan 2011
Posts: 65
R
reknak Offline OP
Junior Member
reknak  Offline OP
Junior Member
R

Joined: Jan 2011
Posts: 65
Thanks for all the comments;

Quote:
My.pan += 4 * (key_a - key_d) * time_step - 20 * mouse_force.x * time_step.
, good trigger, but atm my guy already rotates with the camera, I will keep this one in mind though for future editing laugh.

Quote:
You need to be calling vec_rotate WITHIN the while() loop in camera_follow() I think. Right now it's only being called once... you need to call it every time you reset the camera's position.

Try replacing the existing function with this.
, I tried this but than these functions conflicted with the mouse camera movement because both want to set the camera.

!I was actually wrong with the camera pan, the camera pan rotates well but the x and y coordinates don't move along with the entity. So when the map starts the following line makes sure the x and y coordinates of the camera are good to have a good view (it's set in a while loop),

vec_set(camera.x,vector(50,-100,60)); // camera position relative to the player

, until you want to rotate and move another direction, the camera pan and the entity pan will follow but the x and y coordinates will stay the same, so my question is which lines do I have to use for the x and y coordinates? I hope I'm clear now ;), sorry for the inconvenience.


Last edited by reknak; 01/26/11 19:16.
Re: camera pan and entity pan [Re: reknak] #355475
01/27/11 12:28
01/27/11 12:28
Joined: Dec 2010
Posts: 87
R
romin2011 Offline
Junior Member
romin2011  Offline
Junior Member
R

Joined: Dec 2010
Posts: 87
U set the camera position fixed (50,-100,60) instead camera.x=my.x -50; camera.y=my.y;camera.z=my.z+60 fix the values for ur needs. Hope it was what u ware asking.

Re: camera pan and entity pan [Re: romin2011] #355477
01/27/11 13:06
01/27/11 13:06
Joined: Jan 2011
Posts: 65
R
reknak Offline OP
Junior Member
reknak  Offline OP
Junior Member
R

Joined: Jan 2011
Posts: 65
Quote:
U set the camera position fixed (50,-100,60) instead camera.x=my.x -50; camera.y=my.y;camera.z=my.z+60 fix the values for ur needs. Hope it was what u ware asking.
, this makes the camera follow the unit, but it doesn't move the camera around the unit:

1)When you start the level the camera's position is fine (the arrows show the direction the camera and the unit are facing, ignore the underscores).

___________________camera-> unit->

2)Now lets say I move a little bit forward:

_____________________________camera-> unit->

Nothing is wrong, the camera is following the unit.

3)Now I rotate 180 degrees:

_____________________________<-camera <-unit

Now you can't see the unit, I want to have it like this:

________________________________________<-unit <-camera







Last edited by reknak; 01/27/11 13:09.
Re: camera pan and entity pan [Re: reknak] #355507
01/27/11 16:00
01/27/11 16:00
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67"...
hopfel Offline
User
hopfel  Offline
User

Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67"...
Ahh... you're looking for a 3rd-person view?

I use this code for such things:
Code:
camera.x=my.x-(50)*cos(my.tilt)*cos(my.pan);
camera.y=my.y-(50)*cos(my.tilt)*sin(my.pan);
camera.z=my.z-(50)*sin(my.tilt);
vec_set(camera.pan,my.pan);



I just don't like the vec_rotate-method,
if you want to use vec_rotate, there's an example in the manual, but doesn't make many differents to my code. ^^


Hilf mir, dir zu helfen!
Re: camera pan and entity pan [Re: hopfel] #355522
01/27/11 17:35
01/27/11 17:35
Joined: Jan 2011
Posts: 65
R
reknak Offline OP
Junior Member
reknak  Offline OP
Junior Member
R

Joined: Jan 2011
Posts: 65
Quote:
Ahh... you're looking for a 3rd-person view?

I use this code for such things:

Code:camera.x=my.x-(50)*cos(my.tilt)*cos(my.pan);
camera.y=my.y-(50)*cos(my.tilt)*sin(my.pan);
camera.z=my.z-(50)*sin(my.tilt);
vec_set(camera.pan,my.pan);



I just don't like the vec_rotate-method,
if you want to use vec_rotate, there's an example in the manual, but doesn't make many differents to my code. ^^
, yes your my hero, you will have a place in my hall of fame!! grin It works now!


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