gameobject*.transform.position.y = yPos*
returns error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position’. Consider storing the value in a temporary variable
Using a temporary variable would look like this:
Vector3 giPos = gameobject*.transform.position;*
giPos.y = yPos;
gameobject*.transform.position = giPos;*
In practice, you often want to do a lot more checking and playing with it, so copying into giPos first is easier anyway. It looks like it runs slower, but not really (it has to break it into those three lines anyway, even if you used javascript.)
Why doesn’t C# allow a direct change of position? Just one of those weird C# things, copied from Java.
It seem like your transform is not yet be an object. If it would work please try
Vector3 giPos = new Vector3(gameobject_.transform.position.x,yPos,gameobject*.transform.position.z);*_