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 AnnaLadySG · Feb 28, 2014 at 06:59 PM · itweenitweenpathsine-wave

iTween sine wave like movement

Does anyone know if iTween has an inbuilt script function to move an object in a sine-wave like movement - horizontally across the screen in a straight line, but going slightly up and down at the same time? This is for a 2D game.

I've checked out the iTween reference and haven't found anything immediately obvious, I've also tried using 2 iTween.MoveTo commands one after the other in the script - the first controlling horizontal and the second vertical - but when I do this only the second MoveTo has an effect on the object. The PunchPosition looks like it might do something close - but I need a nice smooth "bobbing along" movement.

Thanks in advance for any help!

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

Answer by robertbu · Feb 28, 2014 at 07:07 PM

I know of no way within iTween, but you may be able to build what you want on top of iTween. That is, you send an empty game object along the path. Your visible object would be a child of the game object moving along the path. Then you attach a script to the child that moves the transform.localPosition of the object up and down. Here is a starter script:

 pragma strict
 
 var bobSpeed = 1.0;
 var bobHeight = 0.5; 
    
 function Update ()
 {
      transform.localPosition = Vector3(0.0, Mathf.Sin(Time.time * bobSpeed) * bobHeight, 0.0); 
 }

I don't know enough about your game. You may have to tweak or add to handle rotation issues or any issues with synchronization.

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 AnnaLadySG · Feb 28, 2014 at 08:07 PM 0
Share

Thanks for the reply - I'd made a start on writing a script to do it without iTween, this is very helpful. I'll give it a try now.

avatar image robertbu · Feb 28, 2014 at 10:02 PM 0
Share

If you want movement without iTween and you are just moving between two fixed points, take a look at the $$anonymous$$oveObject script in the Unity Wiki either as a solution or a starting point.

avatar image AnnaLadySG · Mar 03, 2014 at 12:05 AM 0
Share

thanks! I'll check that out.

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

20 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

iTween not relative to parent 0 Answers

loop a chain of iTween actions 0 Answers

C# - create an iTweenPath in the Sourcecode 1 Answer

3D Text to follow a path; iTween 0 Answers

iTween Path not realtime ?! 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