Hey boxers, There are few folks here in the forum that managed to do this Haptic Feedback feature (phone vibrates after a trigger). I've been looking to do something like this but for Buildbox 3. For instance, after a point / coin collect the haptic feedback (phone vibration) to trigger. Any ideas how to do this with nodes? Or we have to use custom code for that on the already exported project for Xcode as that's native to iOS? https://www.appcoda.com/haptic-feedback/ Best, Itzo
@Vikas has a nice solution for Haptic Feedback, but when a button is pressed on a UI the device vibrates and this would work for BB2 as well as BB3 games. But I do not need it when a button is pressed on UI, but when: If Collide with Actor -> Add Point + 1 If Collide with Actor -> Haptic Feedback (Vibrate) So this can be done with nodes. Partially the @Vikas solution would work, as he's using Custom Navigation button to enable/disable Haptic feedback on device - which is great because it's huge battery drainer. @rizwanashraf shared a code like this: Code: if ( value ) { system.sendHapticFeedback(2); } But how to put it all together? @weboha - you got this right? @rizwanashraf if I do this (edited the Add Point Node): Code: if(value){ let amount = this.attribute('Amount'); this.scene().addScorePoint( amount ); system.sendHapticFeedback(2); } Will it work? Where 2, stands for 2nd level of intensity or something... @weboha what's your value for best results 2 or something else? I am asking because I do not have a device that can test this Haptic Feedback properly, as I am using iPhone 6+ and from a hardware point of view that's missing, yeah I know I have to upgrade On BB3 previewer, I get ReferenceError: system is not defined -> every time point is +1 (added), when I have system.sendHapticFeedback(2); on Add Point node? Is that normal since the previewer is not a device? If not, how do we define the system in sendHapticFeedback? On Xcode, iPhone6+ Device, I get: [PTPlayer] - JS Error [asset: Actor, component: Add Point, line: 12] - ReferenceError: system is not defined -> when a point is added. The point is added correctly to score, but this error is due to the Haptic Feedback system.
yes this code is work for haptic. I used my game. just add when you want to use. this code should be work: if(value){ let amount = this.attribute('Amount'); this.scene().addScorePoint( amount ); System.sendHapticFeedback(1); }
Thanks man, why did you put intensity of 1, instead of 2? When I have this code inside the IF statement, I get this error is console each time coin/point is collected: ReferenceError: system is not defined and this error is Xcode: [PTPlayer] - JS Error [asset: Actor, component: Add Point, line: 12] - ReferenceError: system is not defined
I see now the issue: You have: Code: System.sendHapticFeedback(1); I have: Code: system.sendHapticFeedback(1); it should be System. instead of system. this capital letter is messing the whole thing and system is not defined if it is with small letter 's'
@weboha when implemented this Haptic Feedback for points, have you made any Turn oN/ Off button for Haptic Vibrations? Or there's not an option to disable Haptic Feedback on your game - in Settings maybe?
there is no close button, but you can make. I added a buton to ui. when u click button I changed global var like Settings.haptic=1; u can add a if code, if (Settings.haptic==1)
Interesting, can you provide all the code you did to disable haptic feedback on button press. Was it a navigation button on the UI?
Can you be more precise on how to use navigation button to turn haptic feedback on/off? I'd be appreciated! thx