Search Unity

Assign HingeJoint.spring.targetPosition in C#

Discussion in 'Scripting' started by grooc, Sep 22, 2011.

  1. grooc

    grooc

    Joined:
    May 23, 2011
    Posts:
    15
    Hello

    I get the following error : "Cannot modify a value type return value of `UnityEngine.HingeJoint.spring'. Consider storing the value in a temporary variable"

    for this line of code: hingeJoint.spring.targetPosition = angle;

    i know this problem from this codeline: transform.position.x += 5; but here the solution is transform.position += new Vector3(5, 0, 0);

    But can i do in this case? Any idea?
     
  2. grooc

    grooc

    Joined:
    May 23, 2011
    Posts:
    15
    I found the solution in case someone else needs it:

     
    scionious and dawmat like this.
  3. Rei1

    Rei1

    Joined:
    Aug 22, 2015
    Posts:
    6
    Thank you VERY VERY much for posting your solution ... this was a life-saver!!! Works great.