player Control C# Script

i followed this tut on Youtube and i cant figure out whats wrong with this script could i get some help maybe ?

2253969–150630–playerControl.cs (3.98 KB)

Assets/Scripts/playerControl.cs(95,25): error CS0200: Property or indexer playerControl.velocity' cannot be assigned to (it is read only)** **Assets/Scripts/playerControl.cs(47,33): error CS1612: Cannot modify a value type return value of playerControl.impulse’. Consider storing the value in a temporary variable
Assets/Scripts/playerControl.cs(46,33): error CS1612: Cannot modify a value type return value of playerControl.impulse'. Consider storing the value in a temporary variable** **Assets/Scripts/playerControl.cs(45,33): error CS1612: Cannot modify a value type return value of playerControl.impulse’. Consider storing the value in a temporary variable

are the errors i am getting

This is in the wrong section, it should be in the scripting section. Anyway, could you put the cs file in a paste in so I can see it on my tablet.

figured that out sorry i havnt deleted it. and its on Script Error - Unity Engine - Unity Discussions is the updated and moved version

Well first off in your update method you put " velocity = " however velocity is defined as a read only property. The other errors are because Vector 3 is a struct and transform.position is a getter method. You’d have to change it to:

Vector3 temp = transform.position;
temp.x = Mathf.Clamp (value.x, 0, maxImpulse.x);
temp.y = Mathf.Clamp (value.y, 0, maxImpulse.y);
temp.z = Mathf.Clamp (value.z, 0, maxImpulse.z);
transform.position = temp;