Rotating toward a clicked point

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.
Post Reply
MarvLeonidasX
Posts: 15
Joined: Fri Oct 09, 2009 2:54 pm

Rotating toward a clicked point

Post by MarvLeonidasX »

How do you rotate a vector to face a clicked point. Like in many RPG's when you click on a spot on the ground and your character changes his/her facing toward to clicked spot as he/she moves towards it?

I hope I am making sense.
"Mission failed: Your team was wiped out."
netpipe
Posts: 670
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Post by netpipe »

use the force!
Serg88
Posts: 30
Joined: Mon Oct 19, 2009 5:52 pm
Location: Moscow/Russia

Post by Serg88 »

I see 2 ways

use virtual ISceneNode * getSceneNodeFromRayBB (const core::line3d< f32 > &ray, s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode *root=0)=0

PlayerNode->getPosition().rotationToDirection(TargetNode);

2ways is using
getSceneNodeFromScreenCoordinatesBB
then
getCollisionResultPosition

for example only

Code: Select all

	scene::ISceneManager* smgr = this->device->getSceneManager();
	scene::ISceneCollisionManager * scm = smgr->getSceneCollisionManager();
	core::line3df = scm->getRayFromScreenCoordinates( this->device->getCursorControl()->getPosition() );
	core::vector3df target = scm->getCollisionResultPosition(selector, ...);
//then rotate yours model
PlayerNode->getPosition().rotationToDirection(TargetNode);
it`s complicated, but fewer errors
both function-describe you can find here:

http://irrlicht.sourceforge.net/docu/cl ... nager.html
from Russia with love :))))
Post Reply