Camera Movement Script - Only assignment, call, increment, decrement, and new object

Hi Guys. I would appreciate, if you could help me.
I can’t find anything in the web, which could helped me out.

Here is my Code:

using UnityEngine;
using System.Collections;

public class CameraControl : MonoBehaviour {

	Vector3 moveVect;

	// Use this for initialization
	void Start () {
		//Suchen und initiatliseren von den 2 Steuerungs-Game Objekten
		GameObject handLinks = GameObject.Find ("HandLinks");	
		GameObject handRechts = GameObject.Find ("HandRechts");
		
		//Transformationen des Objektes auf lokales Objekt übertragen
		Transform transLinks = handLinks.transform;
		Transform transRechts = handRechts.transform;
		
		//Position als 3er Vektor
		Vector3 positionLinks = transLinks.position;
		Vector3 positionRechts = transRechts.position;
		
		//altes Ergebnis zwischenspeichern
		Vector3 positionLinksOld = positionLinks;
		Vector3 positionRechtsOld = positionRechts;
	}
	
	// Update is called once per frame
	void Update () {
		transLinks = handLinks.transform;
		transRechts = handRechts.transform;
		
		//altes Ergebnis zwischenspeichern
		positionLinksOld = positionLinks;
		positionRechtsOld = positionRechts;
		
		positionLinks = transLinks.position;
		positionRechts = transRechts.position;
		
		//aktueller Vektor wird zwischengespeichert
		moveVect = transform.position;
		
		//Überprüfung ob sich die linke Hand bewegt hat.
		if(positionLinksOld != positionLinks){
		//Bewegung in Z - Achse
			if(positionLinksOld.z > positionLinks.z) moveVect.z + 10;
			else moveVect.z - 10;
			//Bewegung in Y - Achse
			if(positionLinksOld.y > positionLinks.y) moveVect.y + 10;
			else moveVect.y - 10;
			//Bewegung in X - Achse
			if(positionLinksOld.x > positionLinks.x) moveVect.x + 10;
			else moveVect.x - 10;
		}
		//Überprüfung ob sich die rechte Hand bewegt hat.
		if(positionRechtsOld != positionRechts){
		//Bewegung in Z - Achse
			if(positionRechtsOld.z > positionRechts.z) moveVect.z + 10;
			else moveVect.z - 10;
			//Bewegung in Y - Achse
			if(positionRechtsOld.y > positionRechts.y) moveVect.y + 10;
			else moveVect.y - 10;
			//Bewegung in X - Achse
			if(positionRechtsOld.x > positionRechts.x) moveVect.x + 10;
			else moveVect.x - 10;
		}
		//Da beide Objekte auf diesselbe Kamera Einfluss nehmen, genügt ein gemeinsamer Vektor zum steuern.
		
		//veraänderter Vektor wird auf Kamera gesetzt
		transform.position = moveVect;
	}
}

This is my Error-Message:
“Assets/CameraControl.cs(45,81): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement.”
It is the same Error in the next Lines.

I try to control my Camera with two Empty Objects. They are controlled by a microsoft Kinect.

I would love, if someone could help me out! Thanks

The code at line 45 isn’t correct, but I’m not sure what you’re trying to do:

if(positionLinksOld.z > positionLinks.z) moveVect.z + 10;

Are you trying to add 10 to moveVect.z? If so, you probably want:

if(positionLinksOld.z > positionLinks.z) moveVect.z += 10;

Note the “+=” instead of just “+”.

Most of the lines that follow have the same sort of problem.

Jeff

Thx jgodfrey :slight_smile: