A pet that trails its owner and sits on command
Updated
A pet with a Follow Target trails a hero walking a circle; Sit pauses the follower where it stands and Come lets it catch up again.
Press Sit to stop the pet, and Come to let it run after the hero again. Drag to orbit the camera, scroll to zoom.
A pet that trails its owner and sits on command
#pragma lifecycle(startup)
function startup() { // The Pet group has a Follow Target whose target is 'Hero'. const follow = self.parent.getComponent(FollowTargetComponent); follow.setProps({ offset: { x: 0.8, y: 0, z: 1.2 }, smoothTime: 0.6 });
on('pet/sit', () => { follow.setPaused(true); log('Pet is sitting'); }); on('pet/come', () => { follow.setPaused(false); log('Pet is following'); });}How it works
Section titled “How it works”The script is explained step by step in A pet that trails its owner and sits on command.
Open it in XR Creator
Section titled “Open it in XR Creator”Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.
PetFollow.xrproj