Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: dudebxl on December 10, 2015, 03:25:52 PM

Title: Android Vibrate Advance
Post by: dudebxl on December 10, 2015, 03:25:52 PM
2x Action to set custom vibrations on an Android phone.

Android Vibrate Advance
Option 1. Set the length of vibration in milliseconds
Option 2. Set a vibration pattern in milliseconds with a loop(repeat).

Android Vibrate Advance Array
Using: ArrayList - Only for pattern setup with a loop(repeat). Set a pattern from an int array

Android Vibrate Advance Array2
Using: Array - Only for pattern setup with a loop(repeat). Set a pattern from an int array


Pattern setup:
If set incorrectly, you may get odd behavior(s) as a result!

How does it work:
Element 0 = 0 (start the pattern - Gap in vibration)
Element 1 = Vibrate
Element 2 = Gap in vibration
Element 3 = Vibrate
etc..
Odds are the vibrate and evens are the gaps.

The first index(first pattern) is the start of the pattern and it is a gap. Meaning that 0 is an immediate start. You can delay the start of the vibration by setting the first index to xxxms. Then it is vibrate - gap - vibrate - gap etc.

Repeat: 0 means repeat the pattern starting at the beginning (loop). -1 means repeat/loop is off. Anything above >0 is the amount of times it will vibrate the pattern.

Action Options
Cancel vibration: Will cancel the current vibration. You need to re-enter the action with 'cancel vibration' fsmbool set to true. Do not do this immediately after calling vibrate as it may not have time to even begin vibrating.

Disable Sleep Timeout: When the phone goes to sleep / lock, the vibration will stop. When set to true, the phone will not sleep. Use the 'SetSleepTimeOut' action to reset to whatever setup you need after the vibration is finished.

action in Ecosystem or https://github.com/dudebxl/PlayMakerCustomActions_U5/

A big thanks to PlaymakerNOOB for all his feedback and advice.
Title: Re: Android Vibrate Advance
Post by: PlaymakerNOOB on December 11, 2015, 08:16:16 AM
Works great!  Love it!  Thanks!!!!
Title: Re: Android Vibrate Advance
Post by: dudebxl on February 25, 2016, 09:00:12 PM
*** Update bump

Got my hand on an Android phone and the cancel vibration was not working. It is now working. Updated in ecosystem..
Title: Re: Android Vibrate Advance
Post by: PlaymakerNOOB on May 05, 2017, 08:15:48 PM
AndroidVibrateAdvanceArray.cs is designed for use with playmaker arraymaker proxy, but since 1.8 we dont need those anymore.  Can this be updated to no longer need the proxy?
Title: Re: Android Vibrate Advance
Post by: dudebxl on May 17, 2017, 07:19:22 AM
Ok... hope your wrong cause i still use ArrayList due to the inspector control and hashtable. I will make another action for the array.
Title: Re: Android Vibrate Advance
Post by: dudebxl on May 19, 2017, 09:25:06 AM
Done. Android Vibrate Advance Array2 for PM Array (not tested)

direct link: https://github.com/dudebxl/PlayMakerCustomActions_U5/blob/master/Assets/PlayMaker%20Custom%20Actions/Array/AndroidVibrateAdvanceArray2.cs
Title: Re: Android Vibrate Advance
Post by: PlaymakerNOOB on May 20, 2017, 09:38:37 PM
Thanks Dudebxl.  I found 2 issues with the action

1) The public class should be FsmStateAction

2) Any scene that contains that action will cause the game to crash.  Android Logcat says the error is:

"455 E InputDispatcher: channel '42086c80 com.(nameofmygame)/com.unity3dplayer.UnityPlayerActivity (server) ~ Channel is unrecoverably broken and will be disposed!"
Title: Re: Android Vibrate Advance
Post by: dudebxl on May 21, 2017, 04:45:28 AM
Ooooh good point thanks

I made the change. give it a shot now.. same result?
Title: Re: Android Vibrate Advance
Post by: Deek on October 13, 2017, 04:31:24 PM
Had to bump this post because I found a problem with at least the action "Android Vibrate Advance":
The game always crashes on Android when this action isn't used in the first loaded scene, but the second or any scene afterwards (probably because it's loading the java classes). In Unity everything works, but of course because the Android part gets ignored in the script.
I had this problem before a few months ago when I tried to implement a scene selection and set that as the first scene; whenever I loaded my titlescreen (which utilizes this action) the game crashed.

Now I moved the RumbleManager GameObject that uses this action to the first scene and everything works again.

Since it took me 1-2h to figure out who's the culprit, and because it's likely not that easy to fix, it would at least be helpful if you could warn future users maybe in the description about this or maybe even look into this and try to fix it.

I doubt that it's of relevance, but here are my specs:
Unity 5.6.1f1
PlayMaker 1.8.4
Android 7.1.2
Latest version of the action from the Ecosystem
Title: Re: Android Vibrate Advance
Post by: SamH on February 01, 2021, 10:52:44 AM
Does anyone know if anything exists like this for iOS?I found one simple vibrate function, but nothing with any control over duration or length yet. Thanks
Title: Re: Android Vibrate Advance
Post by: Broken Stylus on February 03, 2021, 11:47:09 AM
A dirty solution would be to time the vibration on iOS, and then decide how many times and at what frequency you need to send the order again so that it covers the wanted duration.
Title: Re: Android Vibrate Advance
Post by: Ghettokon on May 29, 2022, 05:37:07 AM
Hi all, does anyone know or have tried this on a quest 2? Does this automatically translate to touch vibration? Many thanks!