0
$\begingroup$

I'm trying to do something pretty specific with the hair in my character rig; it's highly stylized, attempting to mimic a 2D look. What I want to do is this:

  • Have each chunk of the hair mesh set so it always faces the camera on the x axis (done with the locked track object constraint)

  • When the camera rotates to the other side of the character, have the locked track constraint's influence drop to zero, while a second constraint's influence goes up to 1 as soon as the camera is facing the exact front of the character, so that the hair flips and is now facing the opposite direction, but still locked to the camera.

If my wording is a bit unclear I apologize. I'm familiar with very basic shape key drivers, but I don't know how to do much with drivers in general without following step by step tutorials, and I can't seem to find any for what I want to do. If anyone could help me out I'd really appreciate it, thanks!

Edit 2: added some more detailed images

The right view is the camera view, left view is to see how the hair rotates to face the camera.

1 - Camera is on the character's left, hair object is locked to face it, as can be seen in the object constraints tab.

enter image description here

2 - The hair stays locked on the camera until it faces the front

enter image description here

3 - Here is where I want it to switch, when the camera starts to move to the right of the character. Now I want the first constraint to stop having any influence, and the second one to start, so that the hair flips.

enter image description here

4 - And now the hair, flipped, stays locked onto the camera again, so that it looks flat.

enter image description here

Hopefully this clarifies? There's no animation in the file, so I don't think adding the blend file itself would be very helpful.

$\endgroup$
4
  • $\begingroup$ i would recommend adding a sketch or image if you think your wording is unclear and i think it would help too. ...and...what did you try? where are you stuck at? do you know drivers at all or do you have problems in this specific case? maybe a small example blend file with the animation would too. $\endgroup$
    – Chris
    Commented Jul 12, 2023 at 8:39
  • $\begingroup$ Added some images to clarify! I don't know much about drivers other than how to add the most basic of shape keys unfortunately. $\endgroup$ Commented Jul 12, 2023 at 8:49
  • $\begingroup$ i still have no idea how the hair should look like and where the camera is. The hair looks for me always the same on your pictures. $\endgroup$
    – Chris
    Commented Jul 12, 2023 at 9:53
  • $\begingroup$ Added some new images and descriptions to hopefully help clarify? $\endgroup$ Commented Jul 12, 2023 at 10:57

2 Answers 2

1
$\begingroup$

here is one driver (you have to do the same thing for the other side)

enter image description here

so in my example there are the camera and and empty object.

I have two input parameter (xCam and xObj) which both have the world x coordinate of each object. i can get values from 0 to 1 if the camera is on the left side. And since there is no negative influence possible, i get 0 as result, if the camera is on the right side.

Here you can see it working:

enter image description here

of course (!) you have to adapt this to your special case. So you have to adapt the "/10" to your settings and since you didn't provide a blend file, i cannot know what coordinates your objects are sitting on. I just tried to explain how the principle works. Hope that helps.

$\endgroup$
0
$\begingroup$

To restate the problem, you want an object to rotate about its Z axis to face the camera, unless that would involve a rotation of greater than 90 degrees, in which case, you want the object to face away from the camera.

We have two different locked track constraints. One is set to face the camera. One is set to face away from the camera:

enter image description here

The trick here is, how to tell Blender which one to use at any given moment? We could use scripting, but I'll instead create another object which will be able to tell us which side of the object the camera is on; then, we can create a driver referencing that object to control the influence of our second constraint.

First, we'll create an empty at the location of the head's midline, and parent it to the head. Then, we'll give that empty a floor constraint targeting the camera, with "use rotation" enabled, flooring to the camera's Z plane:

enter image description here

When the camera is pointing at the head, the empty will move to the camera's plane. It will move in its +Y axis if the camera is pointing at the front of the head (as delineated by the "rest" position of the empty) and in its -Y axis if the camera is pointing at the back of the head. So we can use value of this empty's local Y transform to drive the influence of one of our constraints:

enter image description here

When the camera rotates past the Y plane of the resting empty, it switches the second constraint on or off.

$\endgroup$
1
  • $\begingroup$ Had to use the x axis rather than the z one for some reason, but this works PERFECTLY!! Thank you so much, this is going to make a HUGE difference in the style I'm developing for a project. Very easy to follow your directions too, thank you! $\endgroup$ Commented Jul 13, 2023 at 10:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .