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 youngapprentice · Jul 25, 2013 at 05:14 PM · itweenpathcirclecurve

Using iTween.PutOnPath

Hallo!

I'm using iTween.PutOnPath to keep my ship in a defined circle of movement.

I have two issues here that I am sure are solvable.

  1. I want the ship's X and Y axes to be constrained to this circle, but I want it to be able to move up and down freely on the Z axis. How would I acheive this?

  2. I understand that the position of the gamobject on the path is defined by a percentage. If I want to add / decrease percentage as the player presses the Horizontal axes, what do I do when the player is at 100% or 0%? I don't want the percentage to go negative or over 1.0 at any time.

And if you guys can think of a better way to do this, perhaps without iTween, I'd be happy to hear it ;)

Thanks! - YA

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 · Jul 25, 2013 at 05:28 PM

1) Create an empty game object and make the ship a child. Move the empty game object along the path. To change the 'Y', change the 'y' value of transform.localPosition of the visible ship.

2) You can use Mathf.Clamp() to clamp vaues:

 percentage = Mathf.Clamp(percentage+delta, 0.0, 100.0);

3) If it really is a circle, then scripts to do this without iTween are simple. There are lots of different ways to walk the circle depending on the nature of your app. Here is one soluton. Put an empty game object at the center of your circle, place your ship on the circle and make it a child of the empty game object. Then put this script on the empty game object:

 #pragma strict
 
 var percentage = 0.0;
 private var currEuler;
 
 function Update () {
     currEuler = Vector3(0.0, 360.0 * percentage, 0.0);
     transform.eulerAngles = currEuler;
 }

 
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 youngapprentice · Jul 25, 2013 at 05:33 PM 0
Share

Haha that is quite a straightforward and simple solution. Thanks!

Won't the clamp keep me form, say, always going right? What if I reach 100% and want to continue moving in the + direction? Won't the clamp not allow me to do so, effectively making the player have to 'ping pong' around the circle?

avatar image robertbu · Jul 25, 2013 at 05:40 PM 0
Share

Yes it will restrict the movement If you want to iTween and continue to move around the circle, then you would have to something like:

 if (percentage < 0.0)
   percentage = 100.0 - percentage;
 if (percentage > 100.0)
   percentage = percentage - 100;
avatar image youngapprentice · Jul 25, 2013 at 05:43 PM 0
Share

All right. Thank you very much! Your help is appreciated!

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

15 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

Related Questions

iTween, HOTween, Spline Controller and Others 1 Answer

Dynamic animation method ✾ 1 Answer

Dog chasing my player on curved path? 2 Answers

iTween: change parameters during the path 1 Answer

Custom Easing Types using Curves for Motion? 3 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