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
1
Question by latsushi · Sep 29, 2012 at 12:16 AM · c#itween

iTween RotateTo in C#

My character automatically runs forward and I'm trying to SMOOTHLY rotate the camera to an object behind the character by holding down R and then have the character face an object in front of it by releasing R.

My code is below. Any help is appreciated.

     using UnityEngine;
 using System.Collections;
 
 public class Rotation02 : MonoBehaviour {public Transform target; public Transform target2;
 
 
     // Update is called once per frame
     void Update () {
 
        if (Input.GetKeyUp(KeyCode.R))
          iTween.RotateTo(gameObject,iTween.Hash(target.position),"time",2.3f);

I get an error that says: Assets/Standard Assets/Scripts/General Scripts/Rotation02.cs(11,32): error CS1501: No overload for method `RotateTo' takes `4' arguments

Comment
Add comment · Show 4
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 justinl · Sep 29, 2012 at 07:07 AM 0
Share

What is the problem you're having with the code right now?

avatar image latsushi · Sep 29, 2012 at 12:50 PM 0
Share

I get errors:

Assets/Standard Assets/Scripts/General Scripts/Rotation02.cs(11,41): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected

Assets/Standard Assets/Scripts/General Scripts/Rotation02.cs(11,32): error CS1502: The best overloaded method match for `iTween.RotateTo(UnityEngine.GameObject, System.Collections.Hashtable)' has some invalid arguments

Assets/Standard Assets/Scripts/General Scripts/Rotation02.cs(11,32): error CS1503: Argument `#1' cannot convert `object' expression to type `UnityEngine.GameObject'

avatar image latsushi · Sep 29, 2012 at 03:38 PM 0
Share

I edited my post above justinl and deleted that previous post.

avatar image justinl · Sep 29, 2012 at 03:51 PM 0
Share

Thanks latsushi. Your error is due to the fact that ALL the properties of the tween need to be inside of the Hash() parenthesis. Also, each parameter needs a pair of values. The first one telling iTween what property you want to change, and the second one being the value. Your line of code should read: iTween.RotateTo(gameObject,iTween.Hash("rotation", target.position, "time", 2.3f));

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by justinl · Sep 29, 2012 at 12:58 PM

You have several errors in your code:

You cannot convert a transform into a game object. Instead of writing `GameObject(target)`, write `target.gameObject`.

Secondly, you're not giving the tween anywhere to rotate to. It's the equivalent of you saying to someone "hey, rotate to _" but you never actually say where to rotate. The first parameter of RotateTo() tells iTween what GameObject to rotate, and then inside the `Hash()`, you need to specify where to rotate among other additional parameters such as the `easeType` which you are using.

For example inside your Hash() it should say something like `iTween.Hash("x", 25, "y", 90, "z", 0)`. You really should read the official iTween documentation to get a good handle of how to use that method.

Comment
Add comment · Show 3 · 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 latsushi · Sep 29, 2012 at 01:04 PM 0
Share

I read the official iTween documentation for two hours yesterday but I still have trouble. I'll try your suggestions justini. Thank you for your input.

avatar image latsushi · Sep 29, 2012 at 01:07 PM 0
Share

I thought I was telling the tween to rotate to a target that I would select from the project window.

avatar image justinl · Sep 29, 2012 at 01:14 PM 0
Share

the first parameter of RotateTo() should be the object being acted upon. So probably in your case it's going to be the object that this script is attached to, which would be gameObject. Then, the second argument is the the Hash() object, where you specify things such as where you would like the object to rotate to. Since you're probably going to supply a Vector3 type position in space, you can use iTween.Hash("rotation", target.position). Btw no problem. Happy to help!

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

10 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

Related Questions

iTween RotateTo 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Itween gradual jump 2d 1 Answer

Limit distance from start while using iTween 0 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