Rotate towards camera

Posted By: bbn1982

Rotate towards camera - 06/20/18 18:15


// 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

*/
Posted By: 3run

Re: Rotate towards camera - 06/20/18 21:20

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!
© 2024 lite-C Forums