I've downloaded+installed Irrlicht 0.6 about 2 or 3 weeks ago, and I've been messing around with it. I've tried not to post any questions here as newbies tend to asking the same thing. So far, most of my questions have met answers from the Search link.
The problem I'm having is rotating a node to face another one. I've seen the thread by Gorgon Zola, but I don't understand anything in it.
I'm trying to get the angle a node needs to rotate towards, but without actually rotating it. Now, I'm better with trig than matrix math, so I re-wrote Gorgon Zola's function completely. Here's what I got:
Code: Select all
float DTR=(180.0f/3.14159265358979323f);
float faceTarget(ISceneNode *hero, ISceneNode *target){
vector3df hp;
hp=target->getPosition()-hero->getPosition();
return 180+atanf(hp.Z/hp.X)*DTR;
}
Now, the game I'm working on currently has over 1,150 lines of code, so I'll just extract a small peice:
Code: Select all
reg[0]=(int) faceTarget(RID->playerN, player[reg[0]].playerN);
.
.
.
RID->playerN->setRotation(vector3df(0,(float) reg[0], 0));
In DirectX they find the nearest other bot and walk towards it.