3rd person camera?
3rd person camera?
how do you do a 3rd person cam? I no u have to use angles and all those things im not good at. also, i would like to know how to move a simple player forward. I dont mean by the flystraight animator or anyhting, but by calculating movement and angle, and the adding in a camera behind the player. can anyone help?
i looked, but i didnt find wat i wanted.
I think i solved my problem tho. can any1 answer if this can work or not?
take the sin of angley(of ur object), times it by howver much you want to move, and add it to the x position, then take the cos of angle y, times it by the same #, add it to ur z position.(assuming you want 0 degrees to equal facing forward on the z axis)
for the camera, you do the same, except for each (x,z), take away as many as u want(like if u want the camera to be 200 away, -200).
it might look something like this in the device run main loop, basing it off the examples:
(node is object,cam is camera, and ay is angle y)
if(keys[KEY_UP])
{
vector3df v = node->getPosition();
v.X = v.X+20sin(ay);
v.Z = v.Z+20cos(ay);
node->setPosition(v);
}
vector3df cv = node->getPosition();
cv.X = cv.X-200sin(ay);
cv.Z = cv.Z-200cos(ay);
cam->setPosition(cv);
is this close to being right? i only want to move based on the values, not on any special irrlicht things like the animators.
I think i solved my problem tho. can any1 answer if this can work or not?
take the sin of angley(of ur object), times it by howver much you want to move, and add it to the x position, then take the cos of angle y, times it by the same #, add it to ur z position.(assuming you want 0 degrees to equal facing forward on the z axis)
for the camera, you do the same, except for each (x,z), take away as many as u want(like if u want the camera to be 200 away, -200).
it might look something like this in the device run main loop, basing it off the examples:
(node is object,cam is camera, and ay is angle y)
if(keys[KEY_UP])
{
vector3df v = node->getPosition();
v.X = v.X+20sin(ay);
v.Z = v.Z+20cos(ay);
node->setPosition(v);
}
vector3df cv = node->getPosition();
cv.X = cv.X-200sin(ay);
cv.Z = cv.Z-200cos(ay);
cam->setPosition(cv);
is this close to being right? i only want to move based on the values, not on any special irrlicht things like the animators.
-
Eight
Well... I'll answer this out of gratitude to previous posters whose comments helped me out when I was struggling with the same thing.
If you search then somewhere in there you'll find a post with some sample code for a camera animator. I used that as a basis/learning tool.
I created two animators to be attached to my camera - a watch animator and a follow animator. The first sets the target of the camera to be the location of the player mesh. Because the OnEvent method runs so regularly then this works smoothly.
The second takes the rotation and position of the player, and puts the camera a little bit behind him (on the same line of rotation).
Add both animators to a camera and you get a pretty regular sort of 3rd person camera.
This is just a little overview of what I did to point you in a possible direction. I found updating the camera location and target within the main game loop caused hideous flickering and distortion; whereas an animator kept it all looking sweet.
E
If you search then somewhere in there you'll find a post with some sample code for a camera animator. I used that as a basis/learning tool.
I created two animators to be attached to my camera - a watch animator and a follow animator. The first sets the target of the camera to be the location of the player mesh. Because the OnEvent method runs so regularly then this works smoothly.
The second takes the rotation and position of the player, and puts the camera a little bit behind him (on the same line of rotation).
Add both animators to a camera and you get a pretty regular sort of 3rd person camera.
This is just a little overview of what I did to point you in a possible direction. I found updating the camera location and target within the main game loop caused hideous flickering and distortion; whereas an animator kept it all looking sweet.
E