Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
avatar image
0
Question by abhiraavan · Jun 01, 2013 at 05:57 AM · animationrotation

Type of 3D Rotation Animation used in this video

http://youtu.be/IUZqinlhono

I have referred to an application for interactive rotation in 3D space. The same is uploaded on youtube for your reference. I am having difficulty in understanding the rotation of the axis. In the reference app, axis of model moves in bernoulli's lemniscate path. When we swipe horizontal or vertical, it rotates complete 360 degrees however when the angle of swipe is changed (not exactly parallel to X-axis or Y-axis) model's axis moves in lemniscate path and comes back to starting position.

I am not abel to understand the concept and functioning behind this action. I am really stuck and have tried really hard to understand but failed. I will be obliged if anyone helps me understand this.

http://youtu.be/IUZqinlhono

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
0
Best Answer

Answer by robertbu · Jun 01, 2013 at 06:34 AM

I believe it is a simple angle/axis rotation with the object offset from its center of rotation. Put three objects together like this:

alt text

The red sphere is a child of the red block, the red block is a child of the translucent sphere. The block starts on the backside (positive Z) of the sphere. The translucent sphere is only necessary as a visualization aid. It can be replaced by an empty game object. Now attach this script to the translucent sphere:

 using UnityEngine;
 using System.Collections;

 public class AngleAxis : MonoBehaviour {
     private Vector2 v2StartPos;
     private bool bMoving = false;
     
     void Update () {
         
         if (Input.GetMouseButtonDown (0)) {
             bMoving = true;
             v2StartPos = (Vector2)Input.mousePosition;
         }
     
         if (Input.GetMouseButton (0)) {
             if (bMoving)
                 RotateSphere ((Vector2)Input.mousePosition);
         }
         
         if (Input.GetMouseButtonUp(0))
                     bMoving = false;
     }
 
     void RotateSphere(Vector2 fingerPos)
         {
         Vector3 v3Direction = fingerPos - v2StartPos;
         Vector3 v3Axis;
         v3Axis.y = -v3Direction.x;
         v3Axis.x = v3Direction.y;
         v3Axis.z = 0.0f;
         
         gameObject.transform.RotateAround(v3Axis, v3Direction.magnitude/500.0f);
         v2StartPos = fingerPos;
         }
 }

The rotation is not a perfect match, but it is close and you can see by playing a bit with the distances and/or with how the axis is calculated, the two could match. If you play the video and visualize the figure attached to a sphere that is being rotated, the logic of the movements seem clear.


angleaxis2.jpg (19.7 kB)
Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Camera follows rotation. How can I fix it? 4 Answers

Can I make animations snap to a frame? 1 Answer

Animate boss while he's rotating. 1 Answer

AirPlane Sway Effect 1 Answer

Character animations accumulate rotation (update: curve missing) 1 Answer


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