• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Astrydax · May 18, 2016 at 02:11 PM · scripting problemplaymaker

Creating Bloxorz Movement

I'm having a really hard time trying to create bloxorz movement within playmaker. I first set up a really large state machine with itween only to realise that this causes game breaking gimbal locking.

Has anyone successfully created these kind of controls?

Bloxorz video example movement. https://www.youtube.com/watch?v=Z_JTcD_ZIlI

Note: i'm not adverse to writing a C# script to achieve this.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by NoseKills · May 18, 2016 at 05:32 PM

I know nothing of Playmaker and remember even less about iTween. Since you don't post any code, i can give you just pointers about the rotation (not that i would give you a fully working implementation anyways :P )

Because of the inherent issues related to rotation order and gimbal locks when using euler angles, you shouldn't use them when doin sequences like this (in case you tried to).

So basically you have 2 options. A) Use Transform.RotateAround() to rotate your object around it's own center.

 Quaternion startOrientation;
     void Update() {
         if (Input.GetKeyDown(KeyCode.LeftArrow)) {
             StartCoroutine(Rotate90(Vector3.forward));
         } else if (Input.GetKeyDown(KeyCode.RightArrow)) {
             StartCoroutine(Rotate90(Vector3.right));
         }
     }
 
     private IEnumerator Rotate90(Vector3 axis) {
         startOrientation = transform.rotation;
         float amount = 0;
 
         while (amount < 90) {
             yield return new WaitForEndOfFrame();
             var increase = Time.deltaTime * 90;
             amount += increase;
             transform.RotateAround(transform.position, axis, increase);
         }
         transform.rotation = startOrientation;
         transform.RotateAround(transform.position, axis, 90);
     }

B) Make a Quaternion that creates a rotation around a certain axis and multiply your rotation with it. (this might be better because this doesn't affect the position of the object whereas RotateAround might)

 Quaternion startOrientation;
     void Update() {
         if (Input.GetKeyDown(KeyCode.LeftArrow)) {
             StartCoroutine(Rotate90(Vector3.forward));
         } else if (Input.GetKeyDown(KeyCode.RightArrow)) {
             StartCoroutine(Rotate90(Vector3.right));
         }
     }
 
     private IEnumerator Rotate90(Vector3 axis) {
         startOrientation = transform.rotation;
         axis = transform.InverseTransformDirection(axis);
         float amount = 0;
 
         while (amount < 90) {
             yield return new WaitForEndOfFrame();
             amount += Time.deltaTime * 90;
             transform.rotation = startOrientation*Quaternion.AngleAxis(amount, axis);
         }
         transform.rotation = startOrientation * Quaternion.AngleAxis(90, axis);
     }

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Astrydax · May 18, 2016 at 09:21 PM 0
Share

Sorry, Playmaker is a visual scripting editor extension so I'm not sure if it's even possible to post "sample Code".

Thank you very much for the response. This helps out a great deal!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Hi guys. Im with a little problem here. Im using playmaker and when i click play, i click on the scene and appears a gui saying open. I just want the gui when i click only on the door. How can i make that? 0 Answers

Why Collider2D size Y changes affects child object position 0 Answers

When I call a function, It doesn't run completely 0 Answers

How to Undo a lot of created objects at once? [Solved] 1 Answer

error CS1501: No overload for method `FireBurst' takes `0' arguments how have i typo'd here ? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges