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

how to say that in c# ?

Discussion in 'Scripting' started by m-y, Jan 31, 2015.

  1. m-y

    m-y

    Joined:
    Sep 22, 2013
    Posts:
    471
    i want to make object to go in y position
    but it is give me error

    Code (CSharp):
    1. Taba2_Tayyer.gameObject.transform.position.y ++ ;
    i tried to do that
    Code (CSharp):
    1. x= Taba2_Tayyer.gameObject.transform.position.y  ;
    2. x++ ;
    but doesn't work :(
     
  2. Kona

    Kona

    Joined:
    Oct 13, 2010
    Posts:
    208
    What you're doing in your c# attempt is only to copy the y position and then increase the copied value ( and doing nothing to the transforms position. )

    Code (CSharp):
    1. Vector3 curPos = Taba2_Tayyer.transform.position;
    2. curPos.y++;
    3.  
    4. Taba2_Tayyer.transform.position = curPos;
    :) I hope that can help.