Tarantel Geschrieben 5. Oktober 2016 Melden Share Geschrieben 5. Oktober 2016 Tag auch ^^ Ich bins mal wieder mit paar Problemen xD Ich hab hier ein einfaches Bausystem was noch am Anfang ist und naja es kommen nun schon Fehler wo für meine Augen keine sein können da dies vor nem halben Jahr noch funktioniert hat ^^ Gab es in der Zeit schon wieder so gewaltige Änderungen ? Hier mal die Fehlermeldungen: Und hier das Script xD using UnityEngine; using System.Collections; using System.Collections.Generic; public class Buildingsystem : MonoBehaviour { public List<buildObjects> objects = new List<buildObjects> (); public buildObjects currentobject; private Vector3 currentpos; private Vector3 currentrot; public Transform currentpreview; public Transform cam; public RaycastHit hit; public LayerMask layer; public float offset = 1.0f; public float gridSize = 1.0f; public bool IsBuilding; void Start() { //currentobject = objects [0]; ChangeCurrentBuilding (0); Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } void Update() { if (IsBuilding) startPreview (); if (Input.GetButtonDown ("Fire1")) Build (); if (Input.GetKeyDown ("0") || Input.GetKeyDown ("1")) switchCurrentBuilding (); } public void switchCurrentBuilding() { for(int i = 0; i < 2; i++) { if(Input.GetKeyDown("" + i)) ChangeCurrentBuilding(i); } } public void ChangeCurrentBuilding (int cur) { currentobject = objects [cur]; if (currentpreview != null) Destroy (currentpreview.gameObject); GameObject curprev = Instantiate (currentobject.preview, currentpos, Quaternion.Euler(currentrot)) as GameObject; currentpreview = curprev.transform; } public void startPreview() { if (Physics.Raycast (cam.position, cam.forward, out hit, 10, layer)) { if (hit.transform != this.transform) showPreview (hit); } } public void showPreview(RaycastHit hit2) { currentpos = hit2.point; currentpos -= Vector3.one * offset; currentpos /= gridSize; currentpos = new Vector3 (Mathf.Round (currentpos.x), Mathf.Round (currentpos.y), Mathf.Round (currentpos.z)); currentpos *= gridSize; currentpos += Vector3.one * offset; currentpreview.position = currentpos; /*if (Input.GetAxis("Mouse ScrollWheel") > 0f ) // forward { currentrot += new Vector3 (0, 90, 0); } else if (Input.GetAxis("Mouse ScrollWheel") < 0f ) // backwards { currentrot -= new Vector3 (0, 90, 0); }*/ if (Input.GetKeyDown ("Fire2")) currentrot += new Vector3 (0, 90, 0); currentpreview.localEulerAngles = currentrot; } public void Build() { PreviewObject PO = currentpreview.GetComponent<PreviewObject> (); if (PO.IsBuildable) { Instantiate (currentobject.prefab, currentpos, Quaternion.Euler(currentrot)); } } } [system.Serializable] public class buildObjects { public string name; public GameObject prefab; public GameObject preview; //[system.Serializable] //public GameObject preview2; } Zitieren Link zu diesem Kommentar Auf anderen Seiten teilen More sharing options...
Tarantel Geschrieben 5. Oktober 2016 Autor Melden Share Geschrieben 5. Oktober 2016 Ok ich bin einfach zu müde xDDD Fehler gefunden..... hab n , anstatt n ; gemacht xDDDD Zitieren Link zu diesem Kommentar Auf anderen Seiten teilen More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.