Survival Shooter Error CS0120
I'm getting three errors (all CS0120 "An object reference is required for the non-static field, method, or property", 1 on line 13, 2 on line 20) from my CameraFollow script. Even when I use the completed version that comes with the assets, I still get the same errors. Also, the public float and target don't show up in the script component with my script, but do with the premade script (even though they're virtually identical).
My script:
[code=CSharp]using UnityEngine; using System.Collections;
public class CameraFollow : MonoBehaviour { public Transform Target; public float Smoothing = 5f;
Vector3 Offset;
void Start ()
{
Offset = Transform.position - Target.position;
}
void FixedUpdate ()
{
Vector3 TargetCameraPosition = Target.position + Offset;
Transform.position = Vector3.Lerp (Transform.position, TargetCameraPosition, Smoothing * Time.deltaTime);
}
} [/code]
Answer by OncaLupe · Nov 15, 2015 at 07:34 PM
All your Transform.position
needs to be transform.position
. Note the case difference. Unity won't update the Inspector on scripts until all errors are fixed.