Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: cloud03 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?
-
Super!!
It is very useful in my project!
Thank you very much!!!!!
-
Great! glad you found it useful! :D
-
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
-
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);
-
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.
-
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.
-
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?
-
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
-
Hi,
@Cloud03
if You are interested in starting sharing your work on the Ecosystem, I made this available using Snipt (https://snipt.net/jeanfabre/), 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
-
Hi jean,
can you pm me the details of your github, so I can fork it? recently I've learned github :)
cheers,
Romi
-
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 (https://github.com/jeanfabre/PlayMakerCustomActions_U4) is the rep for u4+ actions)
If you need more guidance, let me know.
Bye,
Jean
-
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
-
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
-
Bumping this as it doesn't seem to be available in ecosystem - seems too useful to overlook. Apologies if I'm mistaken!
-
+1 for ecosystem actions with flat/vertical usage toggle ;)
-
Sorry updating old thread, just want to let know I have uploaded this action into Ecosystem.
Cheers!