# New to Trig ideas, Align to Axis help

Edited newerest So I fixed the flippidy flops by just setting a positive vector on the z axis and aligning the objects z to the positive z vector.

``````
# ---- Applies movement to a vector which, based on nilunder Goran's edit of Planetary gravity, is difference between wasd sensors
own.applyMovement(velocity,0)
# ---- A vector that is Vector([0,0,1]) points up, and then this next line aligns the owners z axis (represented by 2) to this point up vect, immediately (represented by 1)
own.alignAxisToVect(updown,2,1)
# ---- this next line says, whatever the velocity vector is, the y axis of the owner object (represented by the first 1) immediately (represented by the second 1) is aligned to it
own.alignAxisToVect(velocity,1,1)

``````

Edited (newest) OKay so It is still doing flippidy flops when it ‘aligns the axis’ even though it says the objects x and y rotation are locked over on the object properties menu (with the lock icons). If yo know the answer to this, help me out, but yeah, that’s where I am at with this.

EDITED after Agoose posted: yo I’m dumb, I just align the axis to the vector I already had… I wish I could have answered this before people saw my stupidity. Anyway, yeah. So, I did that, and then it was doing all kind of flippy flops, so I just locked the x and y transformation. Ok thank you

So I see that I can align things to axis, positive y, positive x,

Why doesn’t ‘negative’ axis work for aligntoaxis, and can someone tell me what method I should be learning how to use instead to solve this problem?

The goal is to have playermovement relative to the global axis, and I was hoping to use aligntoaxis to do diagonal orientation. It works for when I can reference positive quadrants of course, but then you can’t enter ‘negative’ into the vectors.

``````   if velocity:
own.applyMovement(velocity,0)
# ---- Point Right Top
if velocity[0] and velocity[1] &gt; 0:
own.alignAxisToVect([1.0,1.0,0.0], 1, 1.0)

#----- and then you can't do any more this way?

``````

Your question isn’t currently very clear.

If you want to align relative to the negative axis, what you actually mean is that you want to align the given axis (x, y, or z) to the negative of the given vector.

Yeah I just posted too soon, sorry, I got it (edited first post at top)

AlignAxisToVect can be a little temperamental.

Either, align the cross product of the alignment axis and the up axis with the cross product of the direction vector and the up vector,

e.g you want Z to be up and Y to be the align direction,

``````
#Y X Z = X
up = Vector((0, 0, 1))
obj.alignAxisToVect(align.cross(up), 0) # 0 = x

``````

or use Vector((0, 1, 0)).to_track_quat(track, up) to get a quaternion rotation equal to the new world orientation

Thank you for your brainz. I did the first one you suggested minus the align.cross part. I appreciate the 2 methods, because I am interested in wrapping my head around why Quaternions are, and what, and why, etc, so I am very glad you have provided me with an example that uses a method referencing them.

I had been using pages on this site, but just found the Game Module and only recently understood how you apply all the game module method things, whatever they are called. So yeah, thank you agoose for response, confirmation.

Edited: Now I can chop monsters at each one of the 8 infinite directions!