If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
-
siny
- Posts: 10
- Joined: Fri Apr 20, 2007 11:59 am
Post
by siny »
Hi,
I'am having a problem with camera. I want it to follow car. W tried:
Code: Select all
vector3df carPos = carnode->getPosition();
actualCamera->setPosition(core::vector3df(carPos.X+800,carPos.Y+800,carPos.Z));
actualCamera->setTarget(core::vector3df(carPos.X-800,carPos.Y,carPos.Z));
But it don't works like those ones from games. It rotates around the car depends in which way i turn.
How to force it to stay at the back of car and look in the direction of ride??
-
Luben
- Posts: 568
- Joined: Sun Oct 09, 2005 10:12 am
- Location: #irrlicht @freenode
Post
by Luben »
You'll have to transform your 'relativetocar'-vector so that it rotates. It can be done like this
Code: Select all
vector3df RelativeToCar(0,0,-100);
CarNode->getAbsoluteTransformation().TransformVect(RelativeToCar);
CameraNode->setPosition(RelativeToCar);
CameraNode->setTarget(CarNode->getAbsolutePosition());
Then your RelativeToCar will always be 100 units behind the car, no matter what rotation your car has, since the vector is also transformed.
If you don't have anything nice to say, don't say anything at all.