React to touch
このコンテンツはまだ日本語訳がありません。
When to use this
Section titled “When to use this”Use a contact trigger for a headpat, a boop on the nose or a poke on the cheek: a touch area on the avatar that changes something while it is touched, or more and more as a hand comes closer.
For a ready-made headpat, eye touch or nose boop, press + More, then + Contact. On a wide inspector, it sits on the toolbar itself. Your first headpat shows how to make one. To react when someone grabs or poses hair or a tail, see React to PhysBone grabs, poses and stretches.
This needs Advanced mode, the default.
-
In the Hierarchy, select the object that holds your AvatarDoc component.
-
In the inspector's toolbar, press + Trigger. On a narrow inspector, it sits under + More.
You should now see a trigger named New Trigger, selected under Triggers in the tree.
-
In the trigger's panel, type a name into Name, such as Cheek poke, and press Enter.
-
Set When to Contact.
You should now see the contact's settings, with Radius at 0.05 and Touched by set to Finger and Hand.
-
Press the small circle at the right end of Anchor and pick the bone the touch area follows, such as Head. The avatar's bones come first in the list, under Bones.
You should now see the touch area as a sphere on that bone in the Scene view, with handles to move it and to change its size.
-
In the Scene view, drag the handles until the sphere sits where the touch should count. The drags write Offset and Radius in the panel.
-
In Mode, pick how the effect follows the touch:
- Hold switches the effect on while something touches the sphere, and off when it leaves.
- Fade lets the effect grow as a hand comes closer. It starts at the edge of the sphere and is fully on at Fully on at.
In the picture, 1 is When, 2 Mode, 3 Fully on at, 4 Anchor and 5 + And, which the next part uses.
-
In the panel, press + Add effect, then Blendshapes, and pick the shape the touch moves, such as Cheek_Puff. You can also drag objects onto Objects to show or hide them.
Touched by decides which body parts count as a touch. Finger, Hand, Head, Torso and Foot are always shown. More tags shows the rest of VRChat's own tags, such as HandL for the left hand only, and Custom tag adds any other tag.
Who decides whose body counts: Self for your own, Others for other players'. Both are on for a new trigger.
In Hold or Flip mode, Distance chooses Touch to react only on contact, or Closer than to react once something comes within part of the radius.
Add a requirement
Section titled “Add a requirement”A requirement makes the touch count only while something else is true, such as a toggle being on.
-
In the trigger's panel, press + And.
You should now see a group: a box that holds the contact and a new row set to Toggle.
-
On the new row, pick the toggle in Toggle, then choose is on or is off.
A row can also test a parameter, another contact or a PhysBone: change its kind in the list at the top of the row. In Fade mode, the effects rest while any requirement fails, and the group holds the contact and up to three requirements. In Hold or Flip mode, + Or adds another group of conditions, and the trigger fires while any group is fully true.
To switch the reaction on and off from the menu, open the panel's Advanced fold and press Add a menu switch. AvatarDoc makes a toggle named after the trigger, on by default, and the trigger works only while that toggle is on.
What AvatarDoc builds
Section titled “What AvatarDoc builds”At upload, AvatarDoc adds the touch area to the avatar it uploads, never to your scene. It is a VRChat contact on a new object under the anchor, named AD Contact and the trigger's name. Every player's own copy of your avatar senses the touch, so a contact trigger costs no synced bits.
While no hand is near, a Fade trigger writes nothing for the shapes it moves, so face tracking, blinking and your other toggles keep moving them. When the hand leaves, and when the avatar loads, it sets those shapes back to rest once, and never touches the shapes VRChat blinks or speaks with. When its effect moves one of those shapes, VRChat's blinking or lip sync pauses while the effect is on.
Try it with a test hand
Section titled “Try it with a test hand”The test hand is a small sphere in the Scene view that stands in for a hand. Drag it near the avatar and the scene preview shows what your contact triggers do, without Play mode or an upload. It changes only the preview, never the avatar.
- Stop, in the Test touches row.
- Counts as.
- Belongs to.
-
In the trigger's panel, press Test with a hand. It sits in the Test touches row, under the Scene preview row.
You should now see a white sphere in the Scene view, just in front of the trigger's sphere, with handles to move it. The trigger's own handles step aside while the hand runs, so a drag moves only the hand and never the contact. The header has the same button, which starts the hand in front of the avatar's face instead.
-
Drag the white sphere, or its arrows, into the trigger's sphere.
You should now see the trigger's sphere turn green and show its name, and the effect on the avatar. The label beside the hand lists the triggers it touches.
-
Move the hand around and out again:
- A Hold trigger is on while the hand is inside, and off when it leaves.
- A Flip trigger flips its toggle once each time the hand comes in.
- A Fade trigger grows from the edge of the sphere to Fully on at. The hand's label says how far it is on, such as Cheek poke: 50%.
-
Press Stop, in the panel, in the header, or under the hand's label in the Scene view.
You should now see the avatar as it was: every preview the hand set goes back to what it was before.
While the hand runs, the header shows what it stands for:
- Counts as is Hand and fingers by default, so it touches a contact that lists Hand or Finger, and one that lists only a side or a finger, such as HandL or FingerIndexR. Pick Head, Torso, Foot, or Custom tag to try a tag of your own.
- Belongs to is Someone else by default, the way another player pats you. Pick You to try your own hand, which counts only where Self is on.
A requirement on a toggle and the trigger's Only while follow the scene preview: switch the toggle in its own preview row to try both ways. A group of conditions that are all toggles follows the preview too, with no hand needed. Another contact is measured against the hand, and a parameter or a PhysBone counts as met. A trigger with no contact among its conditions, and a blend shape trigger, do not react to the hand. When the hand passes a trigger by, a note under its Test touches row says why.
The hand also goes away when you enter Play mode, select another avatar or something that is not part of the avatar, or the scripts reload, and its previews go with it. A click that selects nothing, or the avatar's own mesh, keeps the hand: use Stop under its label to end it there.
Check it worked
Section titled “Check it worked”- In the trigger's panel, press On in the Scene preview row. The Scene view shows the effect as if the sphere were touched. Press Default to stop the preview.
- Touch the sphere with the test hand, as in Try it with a test hand.
- In Play mode with Gesture Manager, turn on Clickable Contacts and click the sphere in the Game view, as in Your first headpat.
The test hand is measured from its centre, the dot in the middle of the white sphere. A real hand has a size of its own, so in VRChat it starts the touch sooner, and fades a Fade trigger further, than the test hand shows.
If it does not work
Section titled “If it does not work”- Nothing happens when you touch the spot: the sphere sits in the wrong place or is too small, or Touched by leaves out the body part that touches it. Select the trigger and look at the sphere in the Scene view.
- Your own hand works but other players' hands do not, or the other way round: Others or Self is off.
- A Fade effect jumps to full too early: raise Fully on at.
Related
Section titled “Related”- Touch triggers describes every setting of a contact.
- Link effects to another toggle or a parameter explains conditions, groups and Only while.
- A touch or PhysBone trigger never fires in Troubleshooting.
Docs for AvatarDoc 0.7.1