tranform Day0818

using UnityEngine;

using System.Collections;

public class Tank : MonoBehaviour

?{? ?

?public float MoveSpeed;? ?

?//移動速度??

? public float RotaSpeed;? ?

?//旋轉速度? ?

?public float B_Speed;? ? ?

?//炮彈的速度? ? public GameObject Bullet;?

?//要克隆的炮彈? ? public Transform TrGun;??

? public AudioSource ? ? ?AS_iShoot; ?

?public AudioSource AS_BackGround;??

? [Range (0,1)]??

? public float volume;? ?

?public AudioClip QuQu;??

? void Start()??

? { ? ? ? ?//播放背景音樂? ? ? ? AS_BackGround.Play(); ? ? ??

?//背景音樂變為循環播放? ? ? ? AS_BackGround.loop = true;? ? }

?void Update()??

? {? ? ? ?

?AS_BackGround.volume = volume;? ? ?

? transform.Translate(0, 0, Input.GetAxis("Vertical") * Time.deltaTime * MoveSpeed); ? ? ? ? ?transform.Rotate(0, Input.GetAxis("Horizontal") * Time.deltaTime * RotaSpeed, 0);? ? ?

?? if (Input.GetMouseButtonDown(0))? ? ?

?? {? ? ? ? ? ?

?GameObject tempB = Instantiate(Bullet, Bullet.transform.position, Bullet.transform.rotation) as ? ? ? ? ? ? GameObject; ? ? ? ??

? tempB.SetActive(true); ? ? ? ??

tempB.GetComponent(RigidBody).velocity = TrGun.up * B_Speed;? ? ? ? ? ? //tempB.GetComponent(RigidBody).AddForce(TrGun.up * B_Speed, ForceMode.Impulse); ? ? ? //tempB.GetComponent(RigidBody).AddForceAtPosition(TrGun.up*B_Speed,transform.position); ? ? ?

//tempB.GetComponent(RigidBody).AddExplosionForce(1000, );

//播放射擊音效

AS_iShoot.Play();

}

if (Input .GetKeyDown (KeyCode .J ))

{

AS_BackGround.Pause();

}

if (Input .GetKeyDown (KeyCode .K ))

{

AS_BackGround.Play();

}

if (Input .GetKeyDown (KeyCode .L ))

{

AS_BackGround.Stop();

}

if (Input .GetKeyDown (KeyCode .H ))

{

AS_BackGround.Stop();

AS_BackGround.clip = QuQu;

AS_BackGround.Play();

}

}//end_Update

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容