Hi
I’m pretty poor in scripting
I just want to “convert” a js into c# script.
Firstly, my original js script:
var startPoint: Vector3;
var endPoint: Vector3;
var numObjects: int;
var objects: Transform[];
var Road: GameObject;
function Start() {
for (i = 0; i < numObjects; i++) {
var newObj = Instantiate(objects[Random.Range(0, objects.Length)]);
newObj.position = Vector3.Lerp(startPoint, endPoint, (i * 1.0) / (numObjects - 1));
newObj.transform.LookAt(endPoint);
newObj.transform.localEulerAngles.y=270;
}
}
and now what I tried in c#:
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
public void Start() {
public Vector3 startPoint;
public Vector3 endPoint;
public int numObjects;
public Transform[] objects;
public GameObject Road;
for (i = 0; i < numObjects; i++) {
var newObj = Instantiate(objects[Random.Range(0, objects.Length)]);
newObj.position = Vector3.Lerp(startPoint, endPoint, (i * 1.0) / (numObjects - 1));
newObj.transform.LookAt(endPoint);
newObj.transform.localEulerAngles.y=270;
}
}
I get the Error CS1525: Unexpected symbol ‘public’
I want to be able to drag and drop objects into the transform field, so I can’t delete the ‘public’, right?
Or is it different in C#?
Please help