Look at camera with falloff

hi, I’m trying to implement a lookat camera behaviour with a falloff based on distance to the camera, so that the lookat is triggered just inside a certain proximity thresold (from 3 to 8 meters).
Ideally I would like to have multiple objects scatterd in the scene and each one should turn to the FPS camera when the camera is close enough.
It seems straightforward with actor node but I can’t get the distance node to update on each tick
here a sample scene: lookat_falloff
grateful for any suggestion

Very good setup! You were almost there actually.

Have a look at this scene: lookat_falloff

I’ve forked your scene and updated the following:

  • replaced the getObjectProperty by getObjectWorldPosition. The main reason is that the position from the getObjectProperty is in local space, so relative to the parent. So in this setup, as you are checking the distance between 2 objects that are under different parents, it’s safer to compare the world positions.
  • changed the mask in getObject_Camera1 to */perspectiveCamera_FPS. I think yours was just fine, but it’s easier to debug and check that it’s the correct one when it is shorter.
  • added a clamp node after the fit node, to make sure that the lerp would not use values outside of the 0-1 range.

Hope that helps and makes sense. Let me know if not.

Hi Gui,
thanks for pointing me in the right direction.
Here a test scene, still in the process of optimizing: masks_forum
I tested both a copy and an instace version.
Despite using actor node I guess instance can’t read previous frame position/orientation to have a more smooth animation. maybe i should test a particle system?
Can the actor node be used on template points to update instances. I made some test but I didn’t get anything out of it so far

oh, those are beautiful environments and assets! I really like them, thank you for sharing it.

And it looks like all you need to have smooth transition is to lower the lerp parameter of the setObjectLookAt. For instance in this screenshot, I’ve set it to 0.07 and the head gradually turn to me as I approach them.

And that’s correct, the actor nodes operate on individual objects. But I’d like to add a similar node that operates on instances, it would be very useful, especially in a use case like your where you have multiple heavy assets.

In the mean time, there is an alternative. It’s a bit convoluted, but I currently use it when doing rigid body simulations on heavy objects. The sim is actually done on low res non-instanced objects, and then transfered to high res instances. I need to make an official example for this technique, and I may have time later this week. But until that’s available, you could try this:

    1. apply the same actor node you have to a sop/emptyObject, and bypass the hierarchy node you currently have.
    1. create the objects you want to display as instances, and don’t apply an actor node to them. Use the same scatter node to define their positions
    1. add a parent to 1 with the hierarchy node
    1. add an actor node to the hierarchy
    1. merge the hierarchy’s actor and the instances together (not in compact mode, keep them as separate objects)
    1. inside this actor node, you can use getChildrenProperties, setGeometryInstancePositions and setGeometryInstanceQuaternions

here’s a fork of your scene with this update. You’d have to re-create the material that comes with your obj, as the instances need a custom one (you may be able to automatically load the textures that come with your obj file using the sop/decompose node, which you could then assign to the instance material)

@dan.maf I’ve just released an actorInstance node, which should help your setup.

You can see an example here: actor_instance

And I also realised you could also achieve this with the standard actor node if you combine it with the sop/SetGeometry node. The setGeometry node simply allows you to share a geometry with multiple objects. So this gives a similar result to using instances. actor_with_setgeometry

Hope that helps