Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
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
7 registered members (3run, miwok, AndrewAMD, Quad, TipmyPip, fairtrader, 1 invisible), 637 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
3rd person camera view #261785
04/20/09 07:27
04/20/09 07:27
Joined: Mar 2009
Posts: 276
Cebu City, Philippines
boyax Offline OP
Member
boyax  Offline OP
Member

Joined: Mar 2009
Posts: 276
Cebu City, Philippines
Hi,

i'm just wondering... i've browse some codes for 3rd person camera view in which the camera is just on top of the player whenever it moves...

To compute for the camera xyz positions, i see this code like:
Code:
camera.x = player.x - 15 * cos(player.pan);
camera.y = player.y - 15 * sin(player.pan);
camera.z = player.z + 4;


Is it necessary to multiply player.x to cos(angle) ???

I'm thinking, you could get the camera.x by this formula:
Code:
camera.x = player.x - distance_cam_player; //distance_cam_player -> distance bet cam & player


Any advise? Thanks

Re: 3rd person camera view [Re: boyax] #261786
04/20/09 07:32
04/20/09 07:32
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
Yes thats right but your camera wouldn´t rotate with the player. the player could watch to the left, right or anywhere else and the camera would just show him from one side.

that´s why it is multiplyed by "cos(player.pan)" and "sin(player.pan)"

and what you´r doing is exacty the same.

camera.x = player.x - 15
camera.x = player.x - distance_cam_player <-- just give a value

Re: 3rd person camera view [Re: Rasch] #261790
04/20/09 07:52
04/20/09 07:52
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
camera.x = player.x - 15 * cos(player.pan+cam_pan_modifier);
camera.y = player.y - 15 * sin(player.pan+cam_pan_modifier);
camera.z = player.z + 4;

and in your player loop:

cam_pan_modifier +=mouse_force.y*times_tep*10;//10 is mouse speed.


3333333333
Re: 3rd person camera view [Re: Quad] #261792
04/20/09 09:10
04/20/09 09:10
Joined: Mar 2009
Posts: 276
Cebu City, Philippines
boyax Offline OP
Member
boyax  Offline OP
Member

Joined: Mar 2009
Posts: 276
Cebu City, Philippines
what's the cam_pan_modifier?

Re: 3rd person camera view [Re: boyax] #261793
04/20/09 09:24
04/20/09 09:24
Joined: May 2008
Posts: 331
Lithuania, Vilnius
Jaxas Offline
Senior Member
Jaxas  Offline
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
just variable of your, name it as you want wink


The smaller the bug, the harder it is to kill.
_________________________________________
Forklift DEMO (3dgs)
Re: 3rd person camera view [Re: boyax] #261796
04/20/09 09:36
04/20/09 09:36
Joined: Mar 2009
Posts: 276
Cebu City, Philippines
boyax Offline OP
Member
boyax  Offline OP
Member

Joined: Mar 2009
Posts: 276
Cebu City, Philippines
I'm not making it work..supposed to be I (the camera) must sit on top of the player... I just making a simple moving of the player..

Code:
var distance_cam_player = 85;    //distance bet. cam & player
	
///////////////////////////////////////////////////	
action move_cat()
{
  player = my;
	
  while(1)
  {
     handle_movement();
     handle_camera();
     wait(1);
  }
}

function handle_movement()
{
   if(1 == key_w)
   {
      my.x += 5 * time_step;			
   }
   else if(1 == key_s)
   {
      my.x -= 5 * time_step;		
   }
   else if(1 == key_a)
   {
       my.pan += 5 * time_step;				
   }
   else if(1 == key_d)
   {
       my.pan -= 5 * time_step;	
   }	
   wait(1);
}

function handle_camera()
{	
  while (player == NULL) { wait (0); }		
  camera.x = player.x - distance_cam_player * cos(player.pan);
  camera.y = player.y - distance_cam_player * sin(player.pan);
  camera.z = player.z + 24;   //30-6=24 -> z of the camera
  camera.pan = player.pan;	
}


but my output goes to be:



So, its kinda a wrong computation of the camera pan?
Everytime I press W or S, it moves sideways instead moving forward.. but my orientation at the start, the character is facing on its x-axis.. the camera computation have change it..

Any idea? Thanks

Re: 3rd person camera view [Re: Jaxas] #261797
04/20/09 09:37
04/20/09 09:37
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
define it laugh
Code:
action player_act(){
  var cam_pan_modifier = 0;
  var mouse_speed = 10;
  player =me;
  ........//your own needed code here
  while(1){
      camera.x = player.x - 15 * cos(player.pan+cam_pan_modifier);
      camera.y = player.y - 15 * sin(player.pan+cam_pan_modifier);
      camera.z = player.z + 4;
      cam_pan_modifier +=mouse_force.y*times_tep*mouse_speed;
      .....//movement etc code
      wait(1);
  }
}


edit: i was poting this before you posted.

Last edited by Quadraxas; 04/20/09 09:39.

3333333333
Re: 3rd person camera view [Re: Quad] #261799
04/20/09 09:43
04/20/09 09:43
Joined: Mar 2009
Posts: 276
Cebu City, Philippines
boyax Offline OP
Member
boyax  Offline OP
Member

Joined: Mar 2009
Posts: 276
Cebu City, Philippines
Hi Quadraxas,

Yeah, it's ok.

Is there something wrong with my code?
By the way, at the start, the player is already been rotated (pan angle) by 270 degrees...

hope you could help me.. Thanks

Re: 3rd person camera view [Re: Quad] #261800
04/20/09 09:45
04/20/09 09:45
Joined: May 2008
Posts: 331
Lithuania, Vilnius
Jaxas Offline
Senior Member
Jaxas  Offline
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
for movement use c_move function and you get what you want wink


The smaller the bug, the harder it is to kill.
_________________________________________
Forklift DEMO (3dgs)

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