After adding it(to the wrong parameter) it told you that it’s in the wrong position(you added it to the wrong parameter), the ref needs to be added to the THIRD parameter of the method SmoothDamp
void Update () {
transform.position = cameraObject.transform.position + (Quaternion.Euler(0, targetYRotation, 0) * new Vector3(holdSide, holdHeight, 0));
targetXRotation = Mathf.SmoothDamp(targetXRotation, camera.transform.GetComponent<MouseLook>().rotationX, ref targetXRotationV, rotateSpeed);
targetYRotation = Mathf.SmoothDamp(targetYRotation, camera.transform.GetComponent<MouseLook>().rotationY, ref targetYRotationV, rotateSpeed);
}
NOT
void Update () {
transform.position = cameraObject.transform.position + (Quaternion.Euler(0, targetYRotation, 0) * new Vector3(holdSide, holdHeight, 0));
targetXRotation = Mathf.SmoothDamp(targetXRotation, ref camera.transform.GetComponent<MouseLook>().rotationX, targetXRotationV, rotateSpeed);
targetYRotation = Mathf.SmoothDamp(targetYRotation, ref camera.transform.GetComponent<MouseLook>().rotationY, targetYRotationV, rotateSpeed);
}
To hit this home further, you should have gotten the error in MonoDevelop or whatever IDE you’re using before even going back to Unity.
But lets consider the following fake code.
using UnityEngine;
using System.Collections;
public class SomeClass : MonoBehaviour
{
public float a = 0.1f;
public float b = 0.2f;
public float c = 0.4f;
public float d = 0.5f;
// Use this for initialization
void Start ()
{
var d = Mathf.SmoothDamp(a, b, c, c);
}
}
This code would throw the following exception in Unity Editor:
error CS1502: The best overloaded method match for `UnityEngine.Mathf.SmoothDamp(float, float, ref float, float)’ has some invalid arguments
If i put the ref in front of the second parameter:
error CS1502: The best overloaded method match for `UnityEngine.Mathf.SmoothDamp(float, float, ref float, float)’ has some invalid arguments
error CS1615: Argument #2' does not require
ref’ modifier. Consider removing `ref’ modifier
Exception CS1615 and CS1502 are instructing you, the developer, that #1, you have not met the method signature(the parameters do not match the method being called), #2 that you added a ref modifier to the wrong parameter.
Lets remove it from parameter #2 and add it to #4:
error CS1502: The best overloaded method match for `UnityEngine.Mathf.SmoothDamp(float, float, ref float, float)’ has some invalid arguments
error CS1620: Argument #3' is missing
ref’ modifier
A little bit different, but is LITERALLY telling you in this case that it’s missing on parameter #3.
Lets add it to parameter #3.
No Exceptions/Errors