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 Fred_Vicentin · Jul 26, 2013 at 07:18 PM · itweenwaypoint

Move one waypoint on iTween

I have a way point with three points, point A, B and C, I want to move the Waipoint from A to B, then, when click on the button, walk B to C, I tried to add i++ but don't worked, take a look on my code. And thank you =).

 public Transform[] waypoints;
 public float m_speed;
 int i = 1;
 
   public void Update()
     {
       if (jogador == false && Input.GetKeyDown(KeyCode.A))
       {
          i++;
          iTween.MoveTo(player1,iTween.Hash("path",waypoints[i],"speed",m_speed,"easetype","linear"));    
       }
 
     }
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
Best Answer

Answer by robertbu · Jul 26, 2013 at 07:54 PM

Note, you are passing in a Transform, but you are trying to use it like a list of waypoints. In addition you have the problem that if you hit the 'A' key during the time 'player1' is moving, you will end up with multiple iTweens on the player. Here is a bit of code that solves both issues:

 using UnityEngine;
 using System.Collections;
  
 public class Walk : MonoBehaviour {
  
 public Transform[] waypoints;
 public float m_speed = 1.0f;
 public GameObject player1;
 private int i = 0;
 
 private bool moving = false;
     
     public void Start() {
         transform.position = waypoints[0].position;    
     }
     
     public void Update() {
         if (!moving && i < waypoints.Length - 1 && Input.GetKeyDown(KeyCode.A)) {
             i++;
             moving = true;
             iTween.MoveTo(player1,iTween.Hash("position",waypoints[i],"speed",m_speed,"easetype","linear", "oncompletetarget",gameObject, "oncomplete", "Done"));    
         }
     
     }
     
     public void Done() {
         moving = false;
     }
 }

 
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 Fred_Vicentin · Jul 26, 2013 at 08:17 PM 0
Share

Perfect ! Exactly what I need, thank you !

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

orienttopath problem in iTween waypoint ? 0 Answers

iTween and 2D Platforming Tutorial Merge: Rotation of player and camera needed 1 Answer

Tweening the walk of a NPC with charactercollider 1 Answer

iTween : Move Just a Small Portion of a Path? 2 Answers

iTween - Path Movement by Touch 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