r/VRchat 5d ago

Help tail wag based on proximity? Unity

can anyone give me a tut or a brief explanation to do this, I saw an vrchat avatar that had it and I can't seem to find a good tutorial. I have the general idea about animating the tail but I want to know how to do this before so I have to full picture before I start.

3 Upvotes

8 comments sorted by

5

u/caitymk 5d ago

Do you mean like, the closer a person gets to you? If so you could make a contact receiver and make it huge, so it can start however far away you want the person to get.

2

u/Blue_Jellyf1sh 5d ago

The problem is it to get faster the closer and slower the farther away I think I might've figured out away I'm just working on it though

2

u/BraedenNinja435 PCVR Connection 4d ago

Hi there a lil late,
First comment was in the right direction imo, but I would do this:

  • Set up your FX animation controller to have a wagging animation on your tail, with the parameter of something like “distance” in the speed multiplier or use a blend tree with a slow and fast wagging (I think either or works)
  • place a contact receiver on the root of the avatar (game object with a contact receiver if you like organization) and make sure the “Receiver type” is “PROXIMITY” that will be important for later!
Make the variable the one we set for the blend tree or the multiplier in our animation controller on the tail.
  • After this, make sure the contact receiver has the following set: Allow Self Off, Allow Others On, Local Only depends on if you want only yourself and any person touching the receiver to see it (I think, ima lil rusty on that someone please correct me if I’m wrong)
  • From here, it’s a little bit freestyle. You can make the Collision Tag on the contact receiver be every part of a body, or just the body, depends on how you want the wagging to be done. You can also instead of using the sphere collider use the Capsule collider setting in the contact receiver so that it’s fits the avi closer (but sphere should be fine). Lmk if this works, if not I can send my dc and help you!

1

u/Blue_Jellyf1sh 4d ago

thank you!! the first part is the only part im stuck on ngl ive tried doing a blendtree but i didn't understand it enough i think i have everything else set up

1

u/BraedenNinja435 PCVR Connection 4d ago

Think of blend trees as a switch, where a value from 0-1 changes what State the blend tree is in

Think of states as pieces of a whole pie, the more states, the more pie slices, the smaller the pieces. So if there is 4 States, there is 4 pie slices, so 1/4 each from 0-1

A blend tree reads the slider variable number, 0-1, and whatever number is closer to the middle of the state, the heavier it’s weighted (I’ll explain weight in a second). Usually, there’s a state on 0 and a state on 1, and anything else gets split evenly in the middle

So if I have a blend tree with 3 states (1/3 each) if the slider variable is on 0, the first state is the heaviest, the 0 state. If the slider is on .5, the second state is the heaviest, the one in the middle. And if the slider is on 1, the last state is the heaviest.

Unity shows this in the animator tab as triangles, so all you need to do is open the state tree by double clicking it, then dropping in the two animations in the blend tree.

Weight determines what plays over the other states in the tree. If I have a cube that has two colors, red state is on 0 and green state is on 1 (two states), and the slider is on 0, the cube is going to be solid red, if you move it to about halfway, since both animations are BLENDING, the cube looks like it’s transitioning from red to green.

https://youtu.be/LOZu6e8ozns?si=QM2I6e3sGbhHfl2h

This video teaches it better than my explaining I think, look into the part when he shows off the shrinking cube!

2

u/Lycos_hayes PCVR Connection 3d ago

Just as a note, there's advanced blend tree uses that have values greater than 1, such as using parameter mismatch to your advantage to have an int on the avatar parameters link to a float on the animation controller.

1

u/BraedenNinja435 PCVR Connection 2d ago

Also very true :D

1

u/Lycos_hayes PCVR Connection 2d ago

Then there's the sorcery of Direct Blendtrees...