Unity3D学习笔记《Space Shooter》二

来源:互联网 发布:ubuntu win10启动项 编辑:程序博客网 时间:2024/05/01 16:14

写 PlayerController 的时候依然需要修改。

如下。

using UnityEngine;using System.Collections;[System.Serializable]public class Boundary{public float xMin,xMax,zMin,zMax;}public class PlayerController : MonoBehaviour{public Rigidbody rb;public float speed;public Boundary bd;public float tilt;void Start()  {  rb = GetComponent<Rigidbody> (); }  void FixedUpdate()  {  float moveH=Input.GetAxis("Horizontal");  float moveV=Input.GetAxis("Vertical");  Vector3 now = new Vector3 (moveH, 0.0f, moveV);  rb.velocity = now * speed;rb.position = new Vector3(Mathf.Clamp(rb.position.x,bd.xMin,bd.xMax),0.0f,Mathf.Clamp(rb.position.z,bd.zMin,bd.zMax));rb.rotation = Quaternion.Euler (0.0f, 0.0f, rb.velocity.x * -tilt);} }


自己创建子弹材质的时候,fx_bolt_orange需要选择Shader的时候要选择Mobile/particles/Addtive,然后才能选择纹理。


在创建盒子的时候。查找OnTriggerExit函数的时候,提示在history里面。不知道以后还能不能用。


这四章完成。


0 0
原创粉丝点击