• 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 Chris12345 · Jul 02, 2013 at 06:38 PM · itweenitween path

Object appears on itween path?

Hello i have a object that changes paths on button pressed down, the problem is it just appears on the next path and does not move to the path, i want a slow change so that you can see the object change from one path to another? here is my code:

 using UnityEngine;
 using System.Collections;
 
 public class follow : MonoBehaviour {
     //private float smoothing = 1.0f;
     private Vector3 targetPosition;
 
     public float runSpeed = 0;
 
     public Transform[] path0;
     public Transform[] path1;
     public Transform[] path2;
 
     private Transform[][] paths = new Transform[3][];
     private int iPath = 0;
 
 
     float percentsPerSecond = 0.02f; // %2 of the path moved per second
     float currentPathPercent = 0.0f; //min 0, max 1
 
     void Start () {
        paths[0] = path0;
        paths[1] = path1;
        paths[2] = path2;
     }
 
     void Update () {                   
            if (Input.GetKeyDown("a")) {
                 if (iPath == 2) iPath = 1; else iPath = 0;
 
            }
 
            else if (Input.GetKeyDown("d")) {
                 if (iPath == 0) iPath = 1; else iPath = 2;
            }
        currentPathPercent += percentsPerSecond * Time.deltaTime;
        iTween.PutOnPath(gameObject, paths[iPath], currentPathPercent);
        transform.LookAt(iTween.PointOnPath(paths[iPath],currentPathPercent+.05f));
     }
 
     void OnDrawGizmos(){
        iTween.DrawPath(path0);
        iTween.DrawPath(path1);
        iTween.DrawPath(path2);
     }
 }
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 Chris12345 · Jul 02, 2013 at 06:46 PM

sorry solved :)

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

how to use float update for speed in itween,itween how to use float update 0 Answers

How can I save an iTween animation as a .anim file? 1 Answer

How do you get iTween to properly implement PutOnPath command? 1 Answer

Itween path, how to find the closest point to the player/Vector3 2 Answers

iTween Visual Path editor (c#) 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges