playMaker

Author Topic: Android Vibrate Advance  (Read 1039 times)

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Android Vibrate Advance
« on: December 10, 2015, 01: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.
« Last Edit: May 19, 2017, 06:24:14 AM by dudebxl »

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 117
    • View Profile
Re: Android Vibrate Advance
« Reply #1 on: December 11, 2015, 06:16:16 AM »
Works great!  Love it!  Thanks!!!!

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Re: Android Vibrate Advance
« Reply #2 on: February 25, 2016, 07: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..

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 117
    • View Profile
Re: Android Vibrate Advance
« Reply #3 on: May 05, 2017, 05: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?

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Re: Android Vibrate Advance
« Reply #4 on: May 17, 2017, 04: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.

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Re: Android Vibrate Advance
« Reply #5 on: May 19, 2017, 06:25:06 AM »

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 117
    • View Profile
Re: Android Vibrate Advance
« Reply #6 on: May 20, 2017, 06: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!"

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Re: Android Vibrate Advance
« Reply #7 on: May 21, 2017, 01:45:28 AM »
Ooooh good point thanks

I made the change. give it a shot now.. same result?

Deek

  • Junior Playmaker
  • **
  • Posts: 63
    • View Profile
Re: Android Vibrate Advance
« Reply #8 on: October 13, 2017, 01: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