- Home /
Trouble wth Error CS1061
I'm brand new to Unity, and I was following a tutorial on how to make a camera smoothly follow an object. An error popped up and after I fixed it another error popped up that said "Type UnityEngine.Transform' does not contain a definition for
lookAt' and no extension method lookAt' of type
UnityEngine.Transform' could be found. Are you missing an assembly reference?" Being a noob, I have no idea what that means. Here's the script:
using UnityEngine;
public class CameraFollow : MonoBehaviour {
public Transform target;
public Vector3 smoothedPosition;
public float smoothSpeed = 0.125f;
public Vector3 offset;
void LateUpdate ()
{
Vector3 desiredPosition = target.position + offset;
Vector3 smootedPosition = Vector3.Lerp (transform.position, desiredPosition, smoothSpeed*Time.deltaTime);
transform.position = smoothedPosition;
transform.lookAt (target);
}
}
Answer by KittenSnipes · Jan 10, 2018 at 10:31 PM
@AdmiralTNT Well there is only one thing wrong. The last line of your code should be this:
transform.LookAt(target);
Instead of this:
transform.lookAt(target);
Also @ransomink is right you call a Vector3 called smoothedPosition but never use it. Then you call another Vector3 with the same name. So instead you should put:
smoothedPosition = Vector3.Lerp (transform.position, desiredPosition, smoothSpeed*Time.deltaTime);
In place of:
Vector3 smootedPosition = Vector3.Lerp (transform.position, desiredPosition, smoothSpeed*Time.deltaTime);
The only difference is the L is capital but that is Unity's function so you must be case sensitive when typing it. You need to work on being case sensitive because that can make or break your code.
Answer by ransomink · Jan 10, 2018 at 10:39 PM
Make sure to check the Unity API, especially if you are new to coding. It should be transform.LookAt();
with a capital L, not lowercase.
What IDE are you using, Monodevelop or VisualStudio? It should be able to tell you if variables are spelled incorrectly. In this line: Vector3 smootedPosition = Vector3.Lerp (transform.position, desiredPosition, smoothSpeed*Time.deltaTime);
you create a variable called smootedPosition
but in the next line use a different variable smoothedPosition
to set your transform. smoothedPosition
is never set to anything to begin with.
Your answer

Follow this Question
Related Questions
CS 1501 and 1061 appear and says No overload for method `Box' takes `1' arguments 1 Answer
Error with raycast 0 Answers
Changing variable of another object (C#) 1 Answer
Error CS1061 on Mac 0 Answers
Prime31 Social Networking error cs1061 and cs 1579 0 Answers