- Home /
Duplicate Question
Easy C# Question
Im really new to programming. Right now, im tryint to get a cube to chase my player, but I keep getting errors and idk why. Please help. Here is my code:
using UnityEngine; using System.Collections;
public class CubeChase : MonoBehaviour {
var leader : Trasnform; var follower : Transform; var speed : float = 5;
function Update() { follower.LookAt (leader); follower.Translate (speed Vector3.forward Time.deltaTime); } }
and here are the errors: (7,20) unexpected symbol ':' (7,31) unexpected symbol ';' (8,33) unexpected symbol ';' (9,19) unexpected symbol ':' (9,27) unexpected symbol '='
Should be an easy fix I imagine, Thank for your time :)
Answer by robertbu · Oct 07, 2014 at 04:02 AM
You are using Javascript variable declarations in C#. Won't work:
http://answers.unity3d.com/questions/12911/what-are-the-syntax-differences-in-c-and-javascrip.html
For future questions, please format your code. After pasting, select your code and use the 101/010 button.