Question by
MichalxD · Jun 27, 2017 at 06:17 PM ·
error message
How i do fix this error? Assets/CameraController.cs(17,13): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement,Unity Scripts error
using System.Collections; using UnityEngine;
public class CameraController : MonoBehaviour { public Transform sphere;
void Update ()
{
Rigidbody rigidbody = sphere.GetComponent<Rigidbody>();
Vector3 vector = new Vector3(0, 3f, -5f);
float velocity = rigidbody.velocity.sqrMagnitude;
vector = vector * (1f+velocity/25f);
Vector3 newPosition = sphere.position + vector;
transform.position - Vector3.Lerp(transform.position, newPosition, Time.deltaTime*2f);
transform.LookAt(sphere);
}
} ,How i do fix this error Assets/CameraController.cs(17,13): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Comment
Answer by NoseKills · Jun 28, 2017 at 11:19 AM
transform.position - Vector3.Lerp(transform.position, newPosition, Time.deltaTime*2f);
That line is not a valid statement. You are subtracting 2 vectors but not doing anything with the result and that's why it doesn't make sense.
Depending on what you wanted to do, I guess it should be
transform.position = transform.position - Vector3.Lerp(transform.position, newPosition, Time.deltaTime*2f);
Which would be the same as
transform.position -= Vector3.Lerp(transform.position, newPosition, Time.deltaTime*2f);