Search Unity

Novice question about moving in rotation.

Discussion in 'Scripting' started by Endiss, Jan 7, 2014.

  1. Endiss

    Endiss

    Joined:
    Dec 7, 2012
    Posts:
    10
    Hello so i've got question about moving object always forward but in rotation of object way.
    Is it possible to do that? If yes maybe some one got any good tutorial or so.
     
  2. Rome

    Rome

    Joined:
    Oct 12, 2012
    Posts:
    25
    Your question does not seem to make sense. You have a moving object which is always moving forward but you want it to go in a rotation? Or do you want to rotate the object as it is moving?
     
  3. Endiss

    Endiss

    Joined:
    Dec 7, 2012
    Posts:
    10
    $move.png


    Here is a sample that object is moving in rotate direction. Ofc its only for 2d project:)
     
    Last edited: Jan 7, 2014
  4. Rome

    Rome

    Joined:
    Oct 12, 2012
    Posts:
    25
    Ah I got you :), I believe that is called Bezier Curve. Since there is explanation online already I won't go into it. Here is the link with the working code. All you have to do is incorporate it into your project.

    http://answers.unity3d.com/questions/12689/moving-an-object-along-a-bezier-curve.html

    Edit: You would have to change the code a bit to the amount of points you want :), there might be more optimized code but I will leave it up to you to find it.
     
    Last edited: Jan 7, 2014
  5. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Should be something like this:

    Code (csharp):
    1.  
    2. gameObject.transform.position += gameObject.transform.forward * speed * Time.deltaTime;
    3.