5
$\begingroup$

I'm trying to achieve this. Sphere's displacing the position of other objects as they move through them. Sorta like someone pushing through a crowd.

Repel or Evade

I've managed to get this far in AN but adding more than one effector is where I'm getting stuck.

Node setup

It was easy enough to displace the arrows based on an effector but I couldn't get them to choose the most efficient direction to travel. That is why I made them point towards the effector so they could be pushed back on their local X-axis. This adds complexity to the setup that I can't solve now that I need the arrows to "point" to more than one Effector.

Thanks in advance

$\endgroup$
10
$\begingroup$

enter image description here

I divide this Repeller Effect into parts:

  1. Offsetting the locations with multiple-object effectors.
  2. Changing the direction of arrows with respect to the effectors' location.

Part-1: Idea is, we offset the locations (grid-points) using the first effector then use those offsetted grid-points for next the effector with the help of reinitializing option of the loop node.

We want to offset location using more than one effectors (I'm using empties objects), so we need the Loop-Node and looping over effectors to get the location of each effector. enter image description here

Then I have added the Vector-list (name it as grid-points) as "new parameter" in the Loop-Node and calculated the offset by taking the difference between the effector's location and grid-points using Vector-Node which I use as offset-list for the Offset-Node to repel the grid-points based on the Object-Falloff, enter image description here

Now, select the Loop-Node then open the N-panel and reinitialize the grid-points and also enable the output option so that we can use these grid-points for instanced objects which are arrows in this case but you can use any object. Here is the complete setup for this part: enter image description here

Part-2: To calculate the direction for the arrows, I take the difference of effector's location and offsetted grid-points. Now, to get the effect that arrows point toward the effector based on the distance from the effector (e.g. like in case of electric field), so we have to normalize directions w.r.t inverse of distances using Math-Node. You can also change the direction of arrows (i.e. point away or toward the effector) by changing the 1 to -1 in the Math-Node. enter image description here

Next, we add these normalized directions for all effectors which we can do that by creating an empty Vector-list from "new parameter" then reinitializing it and enable the output option for further use in the N-panel, enter image description here

From the outputs of Loop-Node, first, normalize the directions to one then connect them to Direction-To-Rotation node, and then to the Object-Transforms-Output Node, enter image description here

The complete Node-Tree (I have added the Switch-Node to change arrow direction): enter image description here

Note:- This Node-Tree also works for 3DGrid-Points.

$\endgroup$
  • 1
    $\begingroup$ Wow, @3DsinghVFX you are amazing. There is a lot here I didn't know. Thank you. $\endgroup$ – Alan Aug 25 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.