About Store Forum Documentation Contact
Donations:
392$/mo



Post Reply 
Rotating Matrix
Author Message
ronghester Offline
Bronze Supporter

Post: #1
Rotating Matrix
Hi There,

Just trying to figure out, How to smoothly rotate the matrix? I have a object, which is moving (on path points) and it should rotate to face the character but i want that rotation to be smooth so it does not look like a jerk movement.

Currently i am doing it like this but it has a jerk on rotation.

Vec DesiredDir = nextMovePos - lastPosition ;
DesiredDir.normalize();
npcmatrix.setPos(nextMovePos);
npcmatrix.setDir(DesiredDir,Vec(0,1,0);

I also tried lerp between current forward and desiredDir vector but that does not work as expected.

What could be a possible solution here?

Thanks
06-22-2018 03:14 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Rotating Matrix
Please use this method:
Matrix& setRotation(C Vec &pos, C Vec &dir_from, C Vec &dir_to, Flt blend=1); // set as matrix which rotates 'dir_from' to 'dir_to', using blend value, 'dir_from dir_to' must be normalized
06-23-2018 03:37 AM
Find all posts by this user Quote this message in a reply
ronghester Offline
Bronze Supporter

Post: #3
RE: Rotating Matrix
I tried SetRotation as suggested, but it has no effect. Unless the setDir is called matrix is not facing the next point in the path. May be what should be the order for

setPos
SetDir
SetRotation


Let me rephrase the question: If i am moving a object over path (manually) how to make it always look at the next point in the path ? Currently i am using SetDir which works but the rotation is bit jerky ?
06-23-2018 09:36 AM
Find all posts by this user Quote this message in a reply
Post Reply