# convert javascript to c#

**URL:** https://discussions.unity.com/t/convert-javascript-to-c/52715
**Category:** Questions & Answers
**Created:** [October 3, 2012, 11:39pm UTC](https://discussions.unity.com/t/convert-javascript-to-c/52715 "2012-10-03T23:39:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![oOoJaMz93oOo](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@oOoJaMz93oOo](https://discussions.unity.com/u/oOoJaMz93oOo)
#### Post date: [October 3, 2012, 11:39pm UTC](https://discussions.unity.com/t/convert-javascript-to-c/52715/1 "2012-10-03T23:39:54Z")

</div>

hi all i have a script here im trynig to change to c# but failing keep getting errors  
here you will see why im confused i get error saying

Assets/C#Scripts/Player.cs(23,27): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position’. Consider storing the value in a temporary variable

```
  if (transform.position.y <-20)
    		{
    		transform.position.y = 3.5f;
    		transform.position.x = 0.2f;	
    		transform.position.z =-0.1f;	

    		}

```

---

<div class="post-metadata">

### Author: ![AlucardJay](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/alucardjay/32/580106_2.png) [@AlucardJay](https://discussions.unity.com/u/AlucardJay)
#### Post date: [October 3, 2012, 11:56pm UTC](https://discussions.unity.com/t/convert-javascript-to-c/52715/2 "2012-10-03T23:56:22Z")

</div>

For this, you need to follow the advice in the error message : **Consider storing the value in a temporary variable**

Let’s look at that.

```
if (transform.position.y < -20)
{
    // build a temporary Vector3
    Vector3 tempPosition = new Vector3( 3.5f, 0.2f, -0.1f);

    // assign the Vector3 to the transform.position
    transform.position = tempPosition;
}     

```

This is untested and C# is not my native language =]

* * *

Here’s some links I found useful in converting between C# and JS :

> **[What are the Syntax Differences in C# and Javascript? - Unity Answers](https://answers.unity.com/questions/12911/what-are-the-syntax-differences-in-c-and-javascrip.html)**
>
> Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.

[unifycommunity.com](http://www.unifycommunity.com/wiki/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use)?
