Creating a "look at" node set up


#41

Since armory fails compiling for me at the moment (seems like the Kha API changed…), I cannot validate this setup, but this is what I would’ve done. Although it looks just like what you have described about your setup… Maybe, just maybe, there is an issue when not using the x axis as facing, but I really doubt it. I will look into it, once I can compile again.

As far as I know, all the nodes use radians for rotation. There was one which used quaternions, that’s why I inlcuded that output.


#42

@ zaethan
Is it possible to get an object to move in the direction that it is facing? The Translate on Local Axis node doesn’t seem to be working and Translate object only moves in specific set directions.


#43

Front facing axis and Main rotation axis does not have default values :joy:

Setup the axis values , the look at logic node works as expected.

Would it be good to add rotation speed option to the node or make a new node with speed parameter ?
For example some device turning to the player with a constant slow speed, the player can avoid it’s ranged attacks by moving faster.


#44

Yeah, I wasn’t sure about whether I can set default values for vectors in python, so I skipped that. Maybe I should’nt have done that, sorry for wasting your time because of this… But hey, at least it’s working now :grinning:

As for rotation speed, I don’t think this node is the right place for this. Above, you already mentioned that it has many parameters, and adding speed options would make the node even more complex… I think it would be better to use another node to interpolate between the current rotation of the object and the desired rotation (which could be given by the looking at node). This approach would also add the benefit of being independent of the looking at node for speed based rotation.


#45

Translate on Local Axis does not work? It would be the first one I would’ve recommended in this case. You could try using the vector from transform node then.
Like so:


This should do it… Just don’t forget to select the object you want to move in the object node (and also don’t forget to add your nodetree as a trait to an object in the scene).


#46

Does it make sense to everybody that the built-in Look At node should output Euler angles as there is no way to work with the Quat that it outputs ( with built-in nodes, anyway ) and because all of the other nodes use Euler rotation? I want to submit a PR to fix that if everybody thinks that it makes sense.

The LookAt node is exactly what I need for something I’m doing, but I can’t use its output at all with the existing nodes. I could install the logic pack, but I don’t think you should need to in this instance.


#47

@Monte_Drebenstedt I propose you to make your own maths to master precisely what you do and that relatively simply.

What you want is to get a vector that point to a place in the World Space.

To get it, use the Matrice 4x4 of your blue box and substract to it it’s own x,y,z. (that is a kind of (Matblue - Matblue.p)… cf kha.math.FastMatrix4

Then multiply with the 3D position where you want to look at.
(that is (Matblue - Matblue.p) * Matgreen.p )

You must visualize things in vectoriel and use matrix and you will see that’s very simple.


#48

the above node worked great for me. But thanks for the explanation.


#49

I really don’t know any other node that uses quaternions (aside from the QuatToEuler node in the logic pack), so I guess it makes sense to remove the quat output for now.
(Another idea would be to add quats to all other nodes that deal with rotation (and maybe remove euler vectors) to strictly distinguish between rotation and non-rotation input/outputs).