using UnityEngine;
using System.Collections;
/*
* 1
public class Player : MonoBehaviour {
public float Speed = 1;
public GameObject FirePrefab;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
transform.Translate(Speed * new Vector3(h, 0, v));
if(Input.GetButtonUp("Fire1")){
GameObject particle = Instantiate(FirePrefab, transform.position, Quaternion.identity) as GameObject;
float duration = particle.GetComponent<ParticleSystem>().duration;
Destroy(particle, duration);
}
}
}
*/
//2
public class Player : MonoBehaviour {
public GameObject FireParticle;
public int Speed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.Space)){
FireParticle.SetActive(true);
float duration = FireParticle.GetComponent<ParticleSystem>().duration;
Invoke("sleep" , duration);
}
}
void sleep(){
FireParticle.SetActive(false);
}
}
'Computer Language > 유니티' 카테고리의 다른 글
더미와 다이어로그 (0) | 2014.11.10 |
---|---|
캐릭터,리그 ,애니메이터 (0) | 2014.07.21 |
ITWEEN PATH탐지. 쉐이크, 좌우이동 (0) | 2014.07.01 |
코루틴 예제 (0) | 2014.07.01 |
하스스톤 디딤돌 (0) | 2014.07.01 |