[Code=CSharp]
using UnityEngine;
using System.Collections;
public class Drops : MonoBehaviour {
public GameObject brick;
public int brickCount;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update() {
if (Input.GetKeyDown ("x")) {
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, out hit))
Instantiate(brick,hit.point,Quaternion.identity);
if (brickCount == 10)Destroy(gameObject);
}
}
}
[/code]
OK, this scripts purpose is to drop a prefab at ray point, and after it drops 10 prefabs, destroy the game object this script is attached too. But, it is passing 10... and not destroying it. I had help from a friend with this as I'm still learning, so if you comment, your talking to a noob at c#
↧