Shake phone

Hi! , is there I way to if the user is shaking the phone? I’m trying to start a particle emitter when the users shake their phones

I can not find someway to make it, in the documentation I just saw the head, hand shake but thant’s not what I need

Use device motion if you want to shake the phone as trigger.
Use target tracker transform if you want to shake the target tracker as trigger.
Use face tracker transform if you want to shake the head as trigger.
Use hand tracker transform if you want to shake the hand as trigger.
Use body tracking transform from their template to shake any part of the body as trigger.

1 Like

There won’t be a built in function for this, but you can create your own. I think the main problem to consider is that the phone doesn’t exist in world space without a plane tracker, so you won’t get position data from the camera unless you have a plane tracker.

You can try using device motion to detect if a user is shaking the phone, but it might be a little difficult since it only gives you rotation information.

Something like this is probably simpler to make in script, but if you aren’t comfortable with script, you can use delay value to store some variables.

a. Track the number of velocity reversals (e.g. up, down, up, down)
b. Add a counter decay for the reversals since you want to see if it happens quickly. Maybe start with -1 every second and see how that feels.
c. Maybe add a velocity threshold requirement to trigger a reversal (to require strong movements)

You can adapt some of the concepts from this article to determine velocity, and just get an idea of how to use delay value.

1 Like