playMaker

Author Topic: Device Acceleration and Calibrate Device Action  (Read 13425 times)

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Device Acceleration and Calibrate Device Action
« on: January 01, 2015, 02:07:40 AM »
Hi all, I've just created a custom action on how to calibrate the accelerometer, so it doesn't have to be 90 degress pependicular to the ground, also a new get device Acceleration action to work with that.

How it works: the Calibrate Device action are used to store a Quaternion, and this quaternion is retrieved from the device orientation, and then the retrieved Quaternion should be inputed to the get Device Acceleration as a starting base.

I got the idea from here:
http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/space-shooter-to-mobile

I've tested it, and it works, so here is it (let me know if there is any problem with it).

@JeanFabre: how to make this action available on Ecosystem?
« Last Edit: January 10, 2015, 09:55:13 AM by cloud03 »

oijwef

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Device Acceleration and Calibrate Device Action
« Reply #1 on: January 16, 2015, 08:25:26 AM »
Super!!
It is very useful in my project!
Thank you very much!!!!!

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Device Acceleration and Calibrate Device Action
« Reply #2 on: January 16, 2015, 11:31:59 PM »
Great! glad you found it useful!  :D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Device Acceleration and Calibrate Device Action
« Reply #3 on: January 19, 2015, 01:45:06 AM »
Hi,
 
I can put them if you don't want to bother with doing it yourself, but if you are ok with github, you can fork one of my github rep:

if this action works in Unity 3, then:
https://github.com/jeanfabre/PlayMakerCustomActions_U3

if it's a unity 4 only:
https://github.com/jeanfabre/PlayMakerCustomActions_U4

then
-- you put this actions in the PlayMaker Custom Actions folder under the right folder acting as category
-- you add the line //--- __ECO__ __ACTION__ ---// at the top of the script

And fork this back and it will be on the ecosystem to browse and download


Bye,

 Jean

christougher

  • Playmaker Newbie
  • *
  • Posts: 36
Re: Device Acceleration and Calibrate Device Action
« Reply #4 on: March 31, 2015, 05:58:13 AM »
I got the idea from here:
http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/space-shooter-to-mobile

[/quote]

Thanks for this, it will be a lifesaver! I'm having trouble with implementing it though.  I've tried to follow the referenced tutorial to apply the Quaternion but I'm having trouble getting it to work.  This is the code straight from the Unity tutorial I'm trying to follow to set up Playmaker. (Around 29 minutes into tutorial video)

      Vector3 accelerationRaw = Input.acceleration;
      Vector3 acceleration = FixAcceleration (accelerationRaw);  //What does this line actually mean? Does this substitute one v3 for another and if so how do you do that in Playmaker?
      Vector3 movement = new Vector3 (acceleration.x, 0.0f, acceleration.y);
      Rigidbody.velocity = movement * speed);


cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Device Acceleration and Calibrate Device Action
« Reply #5 on: March 31, 2015, 10:35:53 AM »
I'm sorry but I don't quite understand the code, is that the code from the tutorial or the action I've provided in this thread? If you are using the action in this thread, there is no need to alter the code, just simply use the Calibrate Device action to retrieve the quaternion of the device upon calibration, and then use that quaternion value to feed it back as a starting base on the new Device Acceleration action from this thread..

@jeanfabre: sorry I completely missed your post, I'm not quite familiar with github yet as for the moment, if you can put it on ecosystem, I think it would be great and useful for others looking this kind of action in the ecosystem.

christougher

  • Playmaker Newbie
  • *
  • Posts: 36
Re: Device Acceleration and Calibrate Device Action
« Reply #6 on: March 31, 2015, 03:22:20 PM »
I think I was WAY overcomplicating it but I'm still having trouble getting it to work correctly.  And yes, that code snippet is from the referenced video.

So at this point I have three FSM actions as seen in the screen shot.  The quaternion calibrates just fine but can you see an obvious reasons why it's not working?  The ball still rolls as if no calibration has occurred.

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Device Acceleration and Calibrate Device Action
« Reply #7 on: April 01, 2015, 11:04:20 AM »
Could you try adding next frame event to another state after calibration, and put the device acceleration and the add force action to that another state?

christougher

  • Playmaker Newbie
  • *
  • Posts: 36
Re: Device Acceleration and Calibrate Device Action
« Reply #8 on: April 04, 2015, 10:13:11 PM »
Finally got it to work.  Really have no idea why it wasn't working.  After maddening frustration I finally just scrapped the scene I was in and started fresh and it works just like you'd intuitively think.  Again, no idea why I couldn't get it to work before.  This should definitely make it to the Ecosystem! 

Also your "ToDo" section of the code would be much appreciated as well!

Chris

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Device Acceleration and Calibrate Device Action
« Reply #9 on: June 05, 2015, 07:17:09 AM »
Hi,

 @Cloud03

if You are interested in starting sharing your work on the Ecosystem, I made this available using Snipt, an online code sharing ( free, you don't need to go pro for this), and by following simple rules, your actions will become searcheable as any other content on the Ecosystem.

else, I can host them for you if you don't feel like it right now.

 Bye,

 Jean

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Device Acceleration and Calibrate Device Action
« Reply #10 on: June 05, 2015, 10:37:55 PM »
Hi jean,

can you pm me the details of your github, so I can fork it? recently I've learned github :)

cheers,

Romi

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Device Acceleration and Calibrate Device Action
« Reply #11 on: July 23, 2015, 09:17:25 AM »
Hi,

 yes, all my github rep are public:

https://github.com/jeanfabre

So if you want to share an new action, you can clone the related rep ( if in doubt, let me know, but I would say PlayMakerCustomActions_U4 is the rep for u4+ actions)

If you need more guidance, let me know.

Bye,

 Jean

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Device Acceleration and Calibrate Device Action
« Reply #12 on: July 26, 2015, 02:34:51 AM »
Hi Jean,

I've cloned the rep, but when I commited the actions, and want to push it, it was denied, or maybe I'm doing this wrong, could explain it a bit on how to submit the custom actions? Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Device Acceleration and Calibrate Device Action
« Reply #13 on: September 18, 2015, 03:43:03 PM »
Hi,

 I think you need to "fork", but simply give me your github username and I'll add give you access so you can push directly

Bye,

 Jean

grahamH

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Device Acceleration and Calibrate Device Action
« Reply #14 on: October 25, 2015, 09:11:50 AM »
Bumping this as it doesn't seem to be available in ecosystem - seems too useful to overlook. Apologies if I'm mistaken!