7
$\begingroup$

This seems like such a simple request, but I can't find any reference to it anywhere. How do you auto-orient an object so that it faces along its motion path. I don't want to use a path object to create the path, I have a motion path that is defined through keyframes. How do I orient it so that it is always facing forward as it moves?

My thought is to use a driver on the Z rotation that finds the world position of the object 1 frame in the future, subtracts the current world position, and then uses basic trigonometry to work out the rotation necessary.

Unfortunately I don't know enough about the Blender API to be able to implement this, so anyone good at drivers, feel free to help me out.

$\endgroup$
5
  • $\begingroup$ Track To targets another object, doesn't it? That's not what I need. Short of duplicating the object (and its rig) and offsetting the motion 1 frame into the past, which would be a nightmare to edit. $\endgroup$
    – stib
    Jul 15 at 7:43
  • $\begingroup$ yes sorry I first misunderstood your question $\endgroup$
    – moonboots
    Jul 15 at 8:10
  • $\begingroup$ I'm searching for the answer to this exact same question. Any luck? $\endgroup$ Oct 6 at 20:26
  • $\begingroup$ Rather than project forward, can't you just have an empty that trails behind it and then use a constraint to point the back of the object to that? There used to be a 'Slow Parent' option that would be ideal for this, as the child is parented with a slight delay, but that option doesn't seem to be available in the latest versions. You could use drivers to capture it's last position (there's an answer for that somewhere - I'll find it) and then just use a constraint to point its back towards that. $\endgroup$ Oct 6 at 22:22
  • $\begingroup$ Found the related answer for an object following a number of frames behind - see blender.stackexchange.com/a/108484/29586 $\endgroup$ Oct 6 at 22:24
2
$\begingroup$

Same "idea" as Eds...just with some other nodes...

If you don't mind using animation nodes (+ the add-on extension from 3D Singh VFX: https://github.com/3DSinghVFX/animation_nodes), you can do it by subtracting the current position from the old position and this is then your rotation vector. Of course you could do it also via python.

Here is the node setup:

enter image description here

Note: this works only for position changes. I don't know what happens if you animate rotation of that object too....

Note2: of course you could also slice the list so that it doesn't grow to much ;)

result:

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Not as simple, but I like the way this works in more than Z rotation. $\endgroup$
    – stib
    Oct 7 at 11:10
5
$\begingroup$

This can be done using animation nodes. (No scripting required!)

enter image description here

Steps for Blender 2.93.4 and Animation Nodes 2.2:

  1. If not installed, add Animation Nodes to Blender.
  2. Add the object to animate.
  3. Add the keyframes for the object to change it location.
  4. Add the animation nodes below. enter image description here

Explanation:

  1. The fcurves, that stores the keyframe information is pulled from the object
  2. The fcurve for x and y location are isolated
  3. The current and previous frame is input into the fcurve to look up the x and y location for the current and previous frame.
  4. The change in x and y location is calculated to get the vector for the direction for the object.
  5. This vector is converted to an angle.
  6. The angle is put into the object.

The blender file used to generate the animation above is here -

$\endgroup$
5
+50
$\begingroup$

I've made an add-on with this functionality.

https://github.com/crantisz/Orient-to-Motion-Blender

It adds "Orient to Motion" command:

enter image description here

Install as a regular add-on. Run with View3D ⇾ Object ⇾ Animation ⇾ Orient to Motion

May use with Quaternions and Euler angles

Open F9 (adjust last operation) to:

  • Change front axis
  • Set an every frame mode for accuracy (by default, add-on adds keys only on keyframes)
$\endgroup$
4
  • 3
    $\begingroup$ Fantastic work. This should be part of Blender! $\endgroup$
    – stib
    Oct 8 at 3:25
  • $\begingroup$ Great job! But i think i would like it more to see it as a modifier or in a modifier. But as long as Blender does not do this...yours is a great solution! $\endgroup$
    – Chris
    Oct 8 at 6:49
  • 1
    $\begingroup$ I just submitted a pull request, that made it interpolate between KFs better. Agree that it would be better as a modifier. github.com/crantisz/Orient-to-Motion-Blender/pull/1 $\endgroup$
    – stib
    Oct 9 at 12:57
  • $\begingroup$ I'm not sure that it is good as modifier. Checking object position in the neighboring frames should be time consuming and inefficient and it can be tricky to make it effective $\endgroup$
    – Crantisz
    Oct 10 at 16:57

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.