随笔分类 - Unity3D原生
主要分享一些Unity自身的一些东西:)
摘要://发射一条射线,去检测玩家是否在自己面前,用来随后的发射炮弹 bool isForward = false; var TranformShootPoint = ai.WorkingMemory.GetItem("enemyShootPoint"); Ray ray = new Ray(TranformShootPoint.transform.position, TranformShootPoint.transform.forward); RaycastHit hit;//这个是碰撞检测的目标 ...
阅读全文
摘要:using UnityEngine;public class example : MonoBehaviour{ public GameObject projectilePrefab; public float fireRate = 0.5F;//0.5秒实例化一个子弹 private float nextFire = 0.0F; public float speed = 5f;//子弹速度 private void Update() { if (Input.GetButton("Fire1") && Time.time > nextFire) ...
阅读全文
摘要:主要函数:NGUITools.AddChild(gameobj,prefab);//gameobj为父对象,prefab为要显示的窗体对象预制然后写个方法,限制出现多个即可
阅读全文
摘要:SetActive/active/SetActiveRecursively 后两者比较旧,现在通常用第一个SetActive必须先new一个gameobject对象用于实例化,然后再设置其active状态.不然会出错哦 GameObject gb;void Start() { gb = GameObject.FindGameObjectWithTag("Playbutton"); } void OnClick() { if (gb.active == true) { gb.SetActive(false); ...
阅读全文

浙公网安备 33010602011771号