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 ATMEthan · Feb 07, 2013 at 06:10 PM · c#rotationlookatitweenlookrotation

Rotation via iTween.LookTo not working (or using it wrong)

Hello All,

I'm currently trying to get GameObject A to look at or rotate towards GameObject B. But, the iTween function doesn't seem to rotate GameObject A correctly. Or what I need, maybe it is rotating correctly but not what I need. The game is 2D. GameObject A picks a random position outside of the bounds of the screen, teleports there, then it should rotate towards GameObject B(so when it moves on screen it should appear to be looking directly towards GameObject B, and moves towards GameObject B. But GameObject A is always looking towards the top part of the screen.

Please help, and let me know if more information is need or more explanation.

     // Animate the fly to the target node
     protected override void flyToTarget()
     {
         if (targetTile.pickupItem == null)
         {
             _state = StarThiefState.leaving;
             gameObject.SetActiveRecursively(false);    
             return;
         }
         
         MHSoundController.playLoopingSFX(seekSound);
         
         transform.position = positionOutsideOfBoard();
         sprite.PlayAnim(sprite.defaultAnim);
         
         Vector3 starPosition = targetTile.transform.position;
         //starPosition.y += transform.position.y;
         starPosition.z += 30;
 
         
         //rotate and look at target TODO doesn't work
         // Rotate it in the proper direction
         iTween.LookTo(spaceShipIdle.gameObject, iTween.Hash("looktarget", targetTile.transform.position, "axis", "y"));
 
         
         //move to target
         iTween.Stop(gameObject);
         iTween.MoveTo(gameObject, iTween.Hash("position", starPosition, "speed", speed, "easetype", "easeOutSine", "oncompletetarget", gameObject, "oncomplete", "landedOnTarget"));
     }
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 Orc_Horn_Productions · Sep 10, 2015 at 10:25 AM 0
Share

@AT$$anonymous$$Ethan

$$anonymous$$ate got to thank you here, I'm new to iTween and I was struggling to get iTween.LookTo() to work but your script provided the working example I was desperately seeking.

Cheers buddy!

avatar image filibis · Jul 14, 2017 at 09:34 AM 0
Share

Hi, i'm struggling with LookTo feature as well. Do you have any idea why this code doesn't work?

 using UnityEngine;
 using System.Collections;
 
 public class PathCam : $$anonymous$$onoBehaviour
 {    
     void Start(){
         iTween.$$anonymous$$oveBy(gameObject, iTween.Hash(
             "x",3,
             "y",2,
             "z",2,
             "easeType", "easeInOutExpo",
             "loopType", "pingPong",
             "delay", .1
         ));
             
         iTween.LookTo(gameObject, iTween.Hash (
             "looktarget", Eski$$anonymous$$asa.transform.position,
         ));
     }
 }
 
 

Above script gives me this error but i have no idea how to fix. unexpected_symbol

unexpected-symbol.jpg (17.8 kB)

1 Reply

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

Answer by ATMEthan · Feb 07, 2013 at 08:15 PM

...shame on me. It's because of the art asset I was using. It was rotated 90 degrees to the right, hence making the rotation seem wrong. Once, I get the my new art assets I'll verify if it was actually the art asset or not.

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 ATMEthan · Feb 11, 2013 at 02:59 PM 0
Share

yup it was the art asset.

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

Bullet not moving towards player 3 Answers

Look Rotation flipping object rotation after 180 degrees 1 Answer

Flip over an object (smooth transition) 3 Answers

I need help writing a simple script for making an object face the mouse in 2D. 2 Answers

LookRotation is Returning Weird Values 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