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 Raphael 1 · Sep 17, 2010 at 06:49 PM · itween

Simulating rotation-over-edge with iTween

Hello everyone,

I am very very new with Unity and I am trying to make a cube that moves like if it was rotated about one of its edges (simulating a torque). The best way I found so far to implement it perfectly was with iTween, but there is a problem. The first movement always runs perfectly, but in the following ones the cube rotates about a diferente axis. I know it has something to do with local and global coordinates systems, but i cant figure out how to solve it.

The cube has dimensions (1,1,1) and the Script to rotate it (almost) exactly by 1.0 in the z-direction is: (if I simply set up z= 1.0 it doesnt work, so I came up with this)

function Update () {

if (Input.GetKeyDown (KeyCode.UpArrow)){ iTween.moveAdd(gameObject, {"z":.78, "y":.78}); iTween.rotateTo(gameObject, {"x":90}); }

}

Anyone knows how to solve it?! Thanks a lot! =) P.S: I am using iTween 1.X (javaScript)

Comment
Add comment · Show 2
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 Bampf · Sep 17, 2010 at 09:57 PM 0
Share

I fixed your tags; can you change "iTweet" to "iTween" in your question? Thanks.

avatar image Raphael 1 · Sep 18, 2010 at 02:41 AM 0
Share

Fixed. Sorry =)

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by pixelplacement · Sep 21, 2010 at 12:15 AM

Judging by the lower cased functions you are using with iTween ("moveAdd" and "rotateTo") it appeards you are using iTween 1.0.XX. I would STRONGLY recommend you upgrade to 2.0.XX if you can.

This example works for 2.0 and should work with 1.0 as well it allows for rotation in all directions with the arrow keys:

var moving : boolean; var time : float = .4; var easetype : String = "easeinoutsine"; var moveAmnt : float = 1; var rotAmnt : float = .25;

function Update () { if(Input.GetKey("up") && !moving){ moving=true; iTween.MoveTo(gameObject, {"z":transform.position.z+moveAmnt,"oncomplete":"resetMoving","easetype":easetype,"time":time}); iTween.RotateBy(gameObject, {"x":rotAmnt,"easetype":easetype,"time":time}); } if(Input.GetKey("down") && !moving){ moving=true; iTween.MoveTo(gameObject, {"z":transform.position.z-moveAmnt,"oncomplete":"resetMoving","easetype":easetype,"time":time}); iTween.RotateBy(gameObject, {"x":-rotAmnt,"easetype":easetype,"time":time}); } if(Input.GetKey("left") && !moving){ moving=true; iTween.MoveTo(gameObject, {"x":transform.position.x-moveAmnt,"oncomplete":"resetMoving","easetype":easetype,"time":time}); iTween.RotateBy(gameObject, {"z":rotAmnt,"easetype":easetype,"time":time}); } if(Input.GetKey("right") && !moving){ moving=true; iTween.MoveTo(gameObject, {"x":transform.position.x+moveAmnt,"oncomplete":"resetMoving","easetype":easetype,"time":time}); iTween.RotateBy(gameObject, {"z":-rotAmnt,"easetype":easetype,"time":time}); } }

function resetMoving(){ transform.eulerAngles=Vector3.zero; moving=false; }

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 Raphael 1 · Sep 22, 2010 at 01:09 AM 0
Share

Actually, I am very new in Unity, iTween and I have started to learn JavaScript to use in Unity3D but the new version of iTween is only in C# and I dont know how should I proceed. Do I need to write a script in C# in order to call iTween 2.0? Can I only use iTween 1.x if I want my scripts in JavaScript? If not, how should I proceed?!

avatar image
0

Answer by pixelplacement · Sep 22, 2010 at 01:12 AM

You can use iTween 2.0 with JavaScript OR C#. Take a look at the Getting Started page to help you get going! Also, all of the examples are written in both JS and C# if you want to take a look at them.

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

No one has followed this question yet.

Related Questions

Path Controlled Character and Working With Physics on iTween 1 Answer

iTween MoveUpdate Constant Speed? 2 Answers

Can I use iTween to change the parameters of a particles system over time? 1 Answer

iTween PutOnPath normalize percentage based on path length, not node-count? 1 Answer

ITween and Unity Postions. 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