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 supamanu · Jul 08, 2012 at 02:57 AM · c#itweenitweenpath

using iTween in Update() for greater control

I've just started playing around with iTween (and its nifty visual path editor add-on). I was hoping it would help me do one specific thing: control the movement of an object bound to a complex path. But by control, I mean that the speed along the path can vary at any time, including the object stopping or reversing at any point along the path based on user input.

Unfortunately most of the material I have come across points towards a "fire and forget" behaviour, e.g. the MoveTo() method is called in Start() and either the time or speed is fixed for the whole duration of the tween.

I can see in the doc that you can Pause() and Resume(), and there's a MoveAdd() method that seems designed to be used in Update() but is much poorer for options. And I haven't found any good examples to help me figure out how to use them.

Has anyone come across an implementation resembling what I'm trying to achieve?

Comment
Add comment · Show 1
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 supamanu · Jul 08, 2012 at 12:17 PM 0
Share

Thinking about it some more, what bothers me is that in $$anonymous$$oveTo() I can use a "path" key in the hashtable and thus benefit from the visual path editor, but in $$anonymous$$oveUpdate() I have to specify a position in space. So I guess I need to figure a way to reference the path in a different way with $$anonymous$$oveUpdate()...

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by supamanu · Jul 08, 2012 at 04:02 PM

So, after downloading the examples provided by pixelplacement, I hacked this together. Is this the most flexible way to do it? I don't know, we'll see how far I can make this work until I try to do something too fancy for this approach:

public class Player : MonoBehaviour {

// instance variables public float playerSpeed=0.5f; // speed of player on path public Vector3[] controlPath; // reference to the path

private float pathPosition=0;

void Awake() { controlPath = iTweenPath.GetPath ("MainPath"); }

void OnDrawGizmos() { iTween.DrawPath (controlPath, Color.red);

}

// Use this for initialization void Start () {

}

// Update is called once per frame void Update () {

if (Input.GetKey("space")) { pathPosition += playerSpeed * Time.deltaTime; Vector3 coordinateOnPath = iTween.PointOnPath (controlPath, pathPosition); iTween.MoveUpdate (gameObject, iTween.Hash ("position", coordinateOnPath, "time", Time.deltaTime, "orienttopath", true)); if (pathPosition>=1) pathPosition=0; // loop to start of path

}

} }

The good news is I understood how to reference a path drawn with the visual editor :)

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

Answer by Bitpocketer · Dec 30, 2015 at 08:51 AM

I in my project have come to the point where i need to achieve the same functionality. Did this work for you?

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

C# - create an iTweenPath in the Sourcecode 1 Answer

Using iTween to move a gameobject from node to node 1 Answer

Combine iTween with physics acceleration 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 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