[SOLVED] Creating a "look at" node setup

This works for me:

  • The Empty.001 is parented to the object targeting the player
  • The Torus is my Bullet. I also enabled the RigidBody for it in the Blender Physics

The main part of this is the “Fire” Frame in which I first spawn a new Torus (the Bullet) and then set its linear velocity to the scaled “Look” Vector of the Empty to make it move into the right direction.
I also deleted the Bullet from the scene before I spawned a new one, but I am sure there is a better way to do this.

1 Like

It is available along with even more custom nodes in the Logic Pack https://github.com/armory3d/logic_pack. The page also explains how to install it.

Once again - you come to the rescue. I am also going to see if I can figure out how to modify the translate along local axis to become impulse along local axis. I might as well try to create some nodes and add them to the community stuff.

Look at and rotation nodes have bugs.
Why not using Set Transform to make an object use the same look at as another object ?

It works well
http://forums.armory3d.org/t/problem-with-projectile-heading/1902/6

1 Like

I used the set up from @zaethan and it worked fine. But by the looks of it yours would work to.

It works and have been tested.
What is the advantage using other the way ?

I see two main differences here:

  • I spawn a new object and set its transform, you set its location/transform, thus you do not need to remove it like I do, but I think you couldn’t fire multiple bullets at the same time. But the way I set it up, I can’t do that as well, as I remove the bullet before I spawn a new one (I was trying to add some sort of BulletTrait to each spawned bullet, which removes it after a few seconds and thus would allow having multiple bullets on the screen at once, but I ran into issues with the Add Trait node). So if you don’t need multiple bullets at the same time, I would prefer your solution over mine.
  • We use different nodes to make the bullet move. You use Apply Impulse, I use Set Velocity. But the result seems to be the same.
1 Like

I have used @zaethan version and have also been spawning a second before the 1st is removed. What I have found is that as long as you keep the object the same though out the node set up you can have more than one in the scene. By keeping the same, I mean that you have to use the object from the spawn node to attach to anything you want to do with that particular spawned object.

This is not my example, i was helping someone :

http://forums.armory3d.org/t/problem-with-projectile-heading/1902/5

I also would use Velocity, but object mass can’t be 0, and nodes does not have setGravity per object to set it to 0 that is a work around about the mass.

Multiple bullets can be done, using SetTransform , i guess your issue is elsewhere.

How can you constraint rotation to happen only on Z axis ?
Some character facing the player for example.
Is there some doc about this new node ? there is many parameters.

I tried the node but it does not work. It has object and player position as inputs, bu the Euler connected to SetRotation on the object does nothing.

Thank you for this useful logic node :smiley:

Maybe I told you the wrong node - I used one that had limits on which axis. Not at my computer at the monument. Will look again later today to find the right one for you. Sorry about that.

I tried the new node “Look”.
Without connecting it to any node, each time i add it, the compilation fails.

Try the looking at node as shown above

There is no rotation with “Looking at”.

Since you did not mention the “Front facing” and “main axis rotation” inputs, I assume you did not set them.

If you want to rotate on the z axis alone, you would have to set the z axis as the “main rotation axis” and then check "disable secondary rotation.

As for the front facing input, it will most likely be the x or y axis.
As I cannot come up with a good explanation right now, here is a small example: let’s say you have modelled an arrow which is pointing into a certain direction in blender and you want that arrow to target the player in the game. If your arrow points in the x direction in blender, the front facing would be the x axis. If it would point into the y direction, it would be the y axis. You can also let it point somewhere between the x and y axis and then enter a vector which has both x and y components.

  • The vector does not need to be normalized (also applies to the main rotation axis)
  • It is important where the model is pointing to in blender.
  • Thus, do not use the look vector of the “vector from transform” node.

As for documentation, I would have really liked to add some hints to it in blender, like tooltips, when hovering over the different inputs, but I don’t know whether this is possible. Googling it again, it seems like I could add a tooltip to the node itself, which would be displayed when you want to add the node.

Or a little question mark in the top right corner of the node would be great, but I don’t know whether it’s possible with blender nodes.
Another idea: there already is an “open node source” button. So it should be possible to add a “show node help/documentation” button.

2 Likes

I tried

  • front axis : 0 1 0
  • rotation axis : 0 0 1
    It is strangely rotated and rotating, and it quicly change direction when player is 180° behind for example.

You could simply duplicate the thrid person template and make a Blender example like Armory ones, containing different objects in the same scene with different look at setup.
When the player moves around them, they use different look at.

You can also do like Armory examples and add a readme txt note on a lower window.

I think rotation are in radians term.

Are not all setRotation, GetRotation and LookAt nodes using the same format, i mean radians ?
It would be bad design some nodes will work with radians and others with degrees.

Dunno about LookAt but pretty sure that set/getRotation are in radians. Yeah it would be bad tho.
when saying lookat, are we talking about the one in LogicNodes pack?

Yes, the additional pack with “Look” and “Looking At”.
Do you have a working example ?