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
4 registered members (NewbieZorro, Grant, TipmyPip, AndrewAMD), 13,346 guests, and 5 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 chasing target #129608
05/13/07 06:39
05/13/07 06:39
Joined: May 2007
Posts: 5
Vision Offline OP
Newbie
Vision  Offline OP
Newbie

Joined: May 2007
Posts: 5
So i am trying to make a camera follow a entity around, but also allow a player to to rotate the camera 360 degrees around the player model, and also control the height on the camera with a joystick. I have searched around the closest example I have to something similiar to this looked something like this

Code:
// A camera is hunting a target and turns with them, keeping the target always in the middle of the view.
var cam_dist[3] = -500,100,100; // xyz distance vector from camera towards the target

function chase_camera(target)
{
my = target; // The target Entity
// calculate the camera view's direction angle to the target
var cam_ang[3]; // direction angle of the camera to the target.
vec_diff(temp,nullvector,cam_dist);
vec_to_angle(cam_ang,temp);
cam_ang.roll = 0; // roll didn't change vec_to_angle

// permanent updating of the camera's position and angle
while (1)
{
// place the camera at the right position to the target
vec_set(camera.x,cam_dist);
vec_rotate(camera.x,my.pan);
vec_add(camera.x,my.x);
// Set the camera angles to the camera view direction
vec_set(camera.pan,cam_ang);
// and rotate it about the target angle
ang_add(camera.pan,my.pan);
wait(1);
}
}



While I understand some of this 'example' code, I do not see 'temp' defined anywhere, or a reason why it would be neccessary to define 'my' as the target? Albeit I am still learning the ins and outs of Lite-C I was under the assumption 'my' was always in reference to the the target entity.
Anyways if someone could give a better(clearer) example of how I would go about making a working camera chase, or explain this one to me I would greatly appreciate it.

Re: Camera chasing target [Re: Vision] #129609
05/13/07 11:19
05/13/07 11:19
Joined: May 2007
Posts: 5
Vision Offline OP
Newbie
Vision  Offline OP
Newbie

Joined: May 2007
Posts: 5
Cant edit, mod feel free to delete


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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