Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (flink, AndrewAMD), 656 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Rotate towards camera #473194
06/20/18 18:15
06/20/18 18:15
Joined: Jun 2018
Posts: 29
B
bbn1982 Offline OP
Newbie
bbn1982  Offline OP
Newbie
B

Joined: Jun 2018
Posts: 29

// Entity rotate towards camera forever //

action ent_to_camera()
{
while(1){temp.x = camera.x - my.x; temp.y = camera.y - my.y; vec_to_angle(my.pan,temp);wait(1);}
}

/*

I hope this helps someone ...

Have it good! /B

*/

Re: Rotate towards camera [Re: bbn1982] #473197
06/20/18 21:20
06/20/18 21:20
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Hi

Please use [*code] you code here [*/code] tags (without *) to post your code, it will be more readable.
About the code, there is an example how to rotate object to any position (camera as well), in the manual.

Take a look here:
vec_to_angle (ANGLE* ang, VECTOR* dir);

And this is how the code looks like:
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
}


Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

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