# Is it possible to change the HPR of a node through it's vectors?

Hey everyone, I wanted to ask a question, if it is possible to change the HPR of a node through it’s vectors, like instead of using the setHpr() command, could I apply my own vec3s as the node’s Up, Forward, and Right vectors?

Many thanks to anyone willing to help.

Yes. You can use `nodePath.lookAt(nodePath.getPos() + forward, up)` or `nodePath.headsUp(nodePath.getPos() + forward, up)` to apply your forward and up vectors in a way that does not result in skew. (They differ in whether they give precedence to the up or forward vector in case they are not orthogonal).

If you wish to completely specify your own right, forward and up vectors, which may result in a skew transformation if they are not orthogonal, you can use setMat() and apply a 4x4 matrix, in the upper 3x3 of which you put your own three basis vectors.

Thank you for the help, I got a error saying lookUp, does not exist as a node path type, the headsup does not give me the results I want, care to explain how to use the setmat? sorry I,m inexperienced in these advanced concepts.

(in the meantime, I will do some research on it)

I meant lookAt, sorry.

You can do:

``````nodePath.setMat(Mat3(right, forward, up))
``````

This will erase the current position, but you can restore it afterwards with setPos, or use a Mat4 instead to incorporate the position information.

Thanks again, the lookAt came a little closer then the headsUp, but the setMat give a error

AssertionError: has_mat() at line 461 of built1.10/include/transformState.I

I will keep testing and researching.

Which vectors are you passing in to get that message? You must pass in three vectors that are at different angles from each other.

The right, the forward, and up, so what I am trying to do is bypass the headsUp for tilting my character to the HPR of the surface normal because for some reason the heads up is not working properly or like I want it to, so I want to take a more controlled approach.

``````                self.pactor.headsUp(self.pactor, Point3(0, 1, 0), self.surf)
camup = self.pactor.getQuat(self.render).getUp()
camfwd = camup.cross(self.mvtVec)
resPos = self.pactor.getPos(self.render)
self.pactor.setMat(Mat3(self.mvtVec, camfwd, camup))
self.pactor.setPos(resPos)
``````

Looking at the code above, I let the headsUp do it’s thing, then obtain the character’s up vector, the right vector is made from a HPR conversion of the camera and character HPR elsewhere, while the forward vector is a cross between the right and up.

This way the Up is obtained actually while the forward and right are formulated by the player’s movement, because it seems that the headsUp also effects the H to achieve the surface conformity, but with the player also manipulating the H, it is causing the player to fly off the surface.

Edit: it turns out self.mvtVec starts out as Vec3(0, 0, 0) when the game boots up and does not change until movement is made, it seems setMat() does not like a all zero vector, so included a 1 in it and it worked, but it still did not give me the result I want, but rbd you did solve the topic, so I will mark your post as the solution and make a another topic better explaining my situation, thank you vary much for the help

So after days of playing with the Mat3, it turns out I finally got the results I wanted, so another thanks to you, rdb