Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

stuck on how to rotate objects back and forth looping.

Discussion in 'Editor & General Support' started by GoofBall101, Jul 26, 2015.

  1. GoofBall101

    GoofBall101

    Joined:
    Jul 25, 2015
    Posts:
    57
    I got a "leg" that I want to move back and forth on the x axis. all I get is errors so this is what I have been using but many need something else. Thanks.



    publicfloatmin=2f;
    publicfloatmax=3f;

    //Usethisforinitialization
    voidStart () {
    min=transform.rotation.x;
    max=transform.rotation.x+3;
    }

    //Updateiscalledonceperframe
    voidUpdate () {

    transform.rotation =newVector3(Mathf.PingPong(Time.time*2,max-min)+min, transform.Rotate.x);
    }
    }
     
  2. aleks_unity

    aleks_unity

    Unity tech writer/programmer

    Joined:
    Jan 12, 2012
    Posts:
    25
    Hi there, this is a documentation forum, I would recommend posting this in another portion of the forum, if you want to get a better answer.
     
  3. SaraCecilia

    SaraCecilia

    Joined:
    Jul 9, 2014
    Posts:
    675
    Can you tell us which errors you are getting?