Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,248 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
3rd camera perspective must follow a ball #216910
07/19/08 19:14
07/19/08 19:14
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
Hi, i have a tricky problem. I want to make a camera that follow a ball which is moving with physics ( phent_addtorque...). The problem is that i can't use the pan of my player (the ball) for controlling my camera. The camera must look in the direction where the ball is rolling. I think, i need a function that find out this direction. I hope you understand the problem wink

Re: 3rd camera perspective must follow a ball [Re: theDust] #216919
07/19/08 21:52
07/19/08 21:52
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
why can't you use the pan of the ball?

Re: 3rd camera perspective must follow a ball [Re: DJBMASTER] #216920
07/19/08 21:56
07/19/08 21:56
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
The manual is your best friend wink

vec to angle, example section:

Code:
function turn_towards_target()
{
  // get the direction from the entity MY to the entity YOU
  vec_set(temp,your.x); 
  vec_sub(temp,my.x);
  vec_to_angle(my.pan,temp); // now MY looks at YOU
} 



"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: 3rd camera perspective must follow a ball [Re: Michael_Schwarz] #217270
07/22/08 12:08
07/22/08 12:08
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
@DJBMaster Try it and you will see the camera rotates a bid crazy laugh .

Ähm Michael, könntest du mir diese 3 Zeilen Code ein bisschen erklären ? Aus dem Manual werd ich nicht ganz schlau. Was muss ich bei "temp" einsetzen ? Im Manual steht ein Richtungsvector aber welcher ?

Re: 3rd camera perspective must follow a ball [Re: theDust] #217322
07/22/08 17:14
07/22/08 17:14
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
bei temp musst du nichts ersetzen,

ersetze "your" durch "player" und "my" durch "camera", ganz einfach.

Dann den code ausführen in einer schleife und gut is

Last edited by Michael_Schwarz; 07/22/08 17:14.

"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: 3rd camera perspective must follow a ball [Re: Michael_Schwarz] #217327
07/22/08 18:00
07/22/08 18:00
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
Habe das temp immer mit dem Richtungsvector des Spielers ersetzt ^^ Jetzt funktioniert die Kamera.

Re: 3rd camera perspective must follow a ball [Re: theDust] #221417
08/13/08 22:09
08/13/08 22:09
Joined: Jun 2008
Posts: 146
Deutschland
M
M4sterm1nd Offline
Member
M4sterm1nd  Offline
Member
M

Joined: Jun 2008
Posts: 146
Deutschland
bei mir schwenkt die kamera dann zu weit rechts und zu weit runter. die Entity ist quasi oben rechts in der ecke!

weiß jemand wie es dann richtig geht?

Re: 3rd camera perspective must follow a ball [Re: M4sterm1nd] #226206
09/08/08 14:13
09/08/08 14:13
Joined: Jun 2008
Posts: 146
Deutschland
M
M4sterm1nd Offline
Member
M4sterm1nd  Offline
Member
M

Joined: Jun 2008
Posts: 146
Deutschland
ohh ich hatte den mittelpunkt der Entity falsch gesetzt der code läuft!

Re: 3rd camera perspective must follow a ball [Re: M4sterm1nd] #226213
09/08/08 15:13
09/08/08 15:13
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
Code:
function turn_towards_target()
{
  while(1)
  {
     // get the direction from the entity MY to the entity YOU
     vec_set(temp,your.x); 
     vec_sub(temp,my.x);
     vec_to_angle(my.pan,temp); // now MY looks at YOU
     camera.x = you.x - 90; // distance in x direction away from ball
     camera.z = 60; // height of camera
   }
}


You can use this if you also want the camera to follow the movement smile


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