Unity3D学习笔记《Space Shooter》二

写 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值