그냥한다
유니티 VR - Robot Hunter BulletCtrl.cs 본문
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | using System.Collections; using System.Collections.Generic; using UnityEngine; public class BulletCtrl : MonoBehaviour { //총알이 날아가는 속도를 저장하는 변수 public float BulletSpeed; // Start is called before the first frame update void Start() { Destroy(gameObject, 2.0f); } // Update is called once per frame void Update() { //총알은 매 초 BulletSpeed 수치만큼 날아간다. //Time.deltaTime을 해야 조금씩 간다 //transform.position += transform.forward * speed * Time.deltaTime; //현재 위치에서 상대적으로 움직여라 transform.Translate(transform.forward * BulletSpeed * Time.deltaTime); } } | cs |
'유니티' 카테고리의 다른 글
유니티VR - PaletteMgr.cs (0) | 2019.07.23 |
---|---|
유니티VR - DrawMgr.cs (0) | 2019.07.23 |
유니티VR - CastEventToUI.cs (0) | 2019.07.23 |
유니티VR-ViveController.cs (0) | 2019.07.23 |
유니티VR - UI, 레이저 포인터, 텔레포트 기능 (0) | 2019.07.22 |