Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

iTween help getting straight transition to points

Discussion in 'Scripting' started by xtr33me, Nov 9, 2011.

  1. xtr33me

    xtr33me

    Joined:
    Nov 2, 2011
    Posts:
    90
    I'm not sure how to go about doing this. Firstly, I am using c# and I have a laser that I want to move along the outer perimeter of our top down board. I thought that I would be able to do this easily with iTween but I clearly am not getting something here :) I am using the below code:

    Code (csharp):
    1. iTween.MoveTo(myLaser, iTween.Hash("path", new[] { new Vector3(-150, 0, -55), new Vector3(82, 0, -55),
    2.                         new Vector3(82, 0, 70), new Vector3(-150, 0, -55) }, "orienttopath", true, "time", 20,
    3.                         "looptype", iTween.LoopType.loop, "easetype", iTween.EaseType.linear));
    I just want the laser to move on a straight path from vector to vector. When reaching the next point, I would like to rotate the laser and continue to the next point. I think the issue is that I am passing the points as an array and therefore it is drawing the cat-mull path which is adding a curve to my path, but Im unsure as to how to get around this. I thought the easetype would fix that, but I went through all of them and i was just getting different acceleration. Any ideas? Thanks everyone!


    **** EDIT ****
    I have done the below and it works as I want, well...not rotating yet, but just unsure if it is the best way to do it. Just curious what you all think. Thanks again!

    Code (csharp):
    1. void Move1()
    2.     {
    3.         iTween.MoveTo(myLaser, iTween.Hash("position", new Vector3(-150, 0, -80), "orienttopath", true, "time", 5,
    4.                        "looptype", iTween.LoopType.none, "oncompletetarget", this.gameObject, "oncomplete", "Move2",
    5.                        "easetype", iTween.EaseType.linear));
    6.     }
    7.  
    8.     void Move2()
    9.     {
    10.         iTween.MoveTo(myLaser, iTween.Hash("position", new Vector3(82, 0, -80), "orienttopath", true, "time", 5,
    11.                         "looptype", iTween.LoopType.none, "oncompletetarget", this.gameObject, "oncomplete", "Move3",
    12.                         "easetype", iTween.EaseType.linear));
    13.     }
    14.  
    15.     void Move3()
    16.     {
    17.         iTween.MoveTo(myLaser, iTween.Hash("position", new Vector3(82, 0, 70), "orienttopath", true, "time", 5,
    18.                         "looptype", iTween.LoopType.none, "oncompletetarget", this.gameObject, "oncomplete", "Move4",
    19.                         "easetype", iTween.EaseType.linear));
    20.     }
    21.  
    22.     void Move4()
    23.     {
    24.         iTween.MoveTo(myLaser, iTween.Hash("position", new Vector3(-150.0f, 0, 70.0f), "orienttopath", true, "time", 5,
    25.                         "looptype", iTween.LoopType.none, "oncompletetarget", this.gameObject, "oncomplete", "Move1",
    26.                         "easetype", iTween.EaseType.linear));
    27.     }
     
    Last edited: Nov 9, 2011
  2. Narthe

    Narthe

    Joined:
    Dec 13, 2013
    Posts:
    1
    I'm looking forward to do the same thing, your solution may works but seems very heavy. (imagine you have a hundred points path, you can't do 100 "move" methods). We just need to figure out where itween uses the Catmull-Rom splines to make the path.
     
    Last edited: Jan 23, 2014
  3. lamxung55

    lamxung55

    Joined:
    Aug 1, 2014
    Posts:
    10
    Can anyone tell me what is the Catmull-Rom??? I have the same problem. Thank you