第一个工程3-代码解释二
来源:互联网 发布:qq飞车淘宝网 编辑:程序博客网 时间:2024/04/30 00:55
绑定在球杆上对球杆的控制,之所以还有个绑在空物体上的球杆控制,是由于一个物体不能SetActive(true)本身
StickSelfHitRelated.cs
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class StickSelfHitRelated : MonoBehaviour {
public GameObject tableStickController;
public GameObject whiteBallParticleSystem;
private StickController stickController;
private Vector3 startDirection; //水平方向
public GameObject hitPowerGameObject;
private Slider hitPower;
//system configure
// private float whiteBallStartSpeed = 10.0f;
// Use this for initialization
void Start () {
stickController = tableStickController.GetComponent<StickController> ();
hitPower = hitPowerGameObject.GetComponent<Slider> ();
}
// Update is called once per frame
void Update () {
}
//这个碰撞是指杆和白球碰撞
void OnTriggerEnter(Collider other) {
if (other.gameObject.CompareTag ("WhiteBall")) { //当杆的碰撞对象为
startDirection = stickController.hitVector; //从stickController取得击球方向,这个向量y方向应该为0
gameObject.transform.parent.gameObject.SetActive (false); //球杆消失,由于方向问题,碰撞体在子物体上,把父物体Active设为false,子物体跟着消失。
whiteBallParticleSystem.SetActive (false); //白球上的击球线消失
other.gameObject.GetComponent<Rigidbody> ().velocity = startDirection * hitPower.value/5.0f; //根据滚动条的值赋给白球速度,这样简单点
SceneManager.isBallMoving = true; //设为true,表示一杆的开始,设为false,一杆结束是判断所有还存在的球静止时
SceneManager.changePlayer = false; //在一杆把是否变换Player的标志位设为false,方便后面的处理,只有发生交换击球的情况才再改变changePlayer
}
}
}
- 第一个工程3-代码解释二
- 第一个工程3-代码解释一
- 第一个工程3-代码解释二 ,检查球的的静止和一杆的结束
- android学习(二)——第一个android工程
- Maven之开始手工搭建第一个maven工程(二)
- 用Leiningen创建第一个Clojure工程二
- Win32应用程序工程学习笔记二 - 构建第一个窗口
- 创建第一个Android 3 工程
- IOS5编程-3-第一个工程
- 第一个xfire工程
- 第一个Android工程
- 第一个hibernate工程
- 第一个android工程
- EEPlat第一个工程
- 第一个jni工程
- jfinal第一个工程
- 第一个QT工程
- 第一个SpringBoot工程
- 拓扑排序以及关键路径总结
- curl进行传值(post提交请求)
- iOS多线程编程——浅谈GCD
- JavaScript学习笔记--08
- tomcat 性能优化
- 第一个工程3-代码解释二
- Linux watch命令
- service
- 用Delphi实现文件下载的几种方法
- Linq修改Web.config的连接字符串
- 广播的最佳实践-实现强制下线功能
- 关于java的引用传递(copy百度问答)
- 顺时针打印矩阵
- 二、android.support.v7.app.ActionBarActivity is deprecated; use AppCompatActivity instead