Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- map
- photon
- ARface
- 유니티슈팅게임
- Vector
- Java
- NotFoundException: String resource ID #0x0
- 포톤
- 세마포
- unorderedmap
- list
- 유니티
- dependencyResilutionManagement
- mutex
- SpinLock
- registerForActivityResult
- 지크슈
- 스핀락
- 게임개발
- 안드로이드스튜디오
- 바이너리세마포
- C++
- 동기화
- Unity
- StartActivityForResult
- unorderedset
- 광유다
- 뮤텍스
- unityAR
- semaphore
Archives
- Today
- Total
와와
[ Unity 슈팅게임 ] 3. 마우스 클릭으로 총알 발사 본문
< Bullet.cs >
: 총알 오브젝트 (프리펩)
- 생성된 총알은 직선으로 쭉 나아감
- 총알 오브젝트가 화면 밖( y축으로 1000 이상 )을 벗어나면 삭제
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
public float bulletSpeed = 15f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Translate(Vector3.up * Time.deltaTime * bulletSpeed);
Vector3 view = Camera.main.WorldToScreenPoint(transform.position);
if (view.y > 1000)
{
Destroy(gameObject);
}
}
}
< Fire.cs >
: 플레이어 오브젝트
- 마우스 클릭하면 플레이어 위치에서 총알 생성
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Fire : MonoBehaviour
{
public GameObject BulletFactory;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if ( Input.GetMouseButtonDown(0))
{
Instantiate(BulletFactory, transform.position, transform.rotation);
}
}
}
'개발 > Unity 3D' 카테고리의 다른 글
[ Unity 슈팅게임 ] 5. 움직이는 배경, 메뉴 씬, 실행 화면 (0) | 2022.08.20 |
---|---|
[ Unity 슈팅게임 ] 4. 게임 오버, 스코어 기록, 랭킹 (0) | 2022.08.20 |
[ Unity 슈팅게임 ] 2. 적 오브젝트/ 랜덤생성/ 충돌 설정 (0) | 2022.08.19 |
[ Unity 슈팅게임 ] 1. 카메라/ 해상도/ 플레이어 방향키 움직임 (0) | 2022.08.19 |
Unity AR 얼굴 인식 ( AR Face Manager ) (0) | 2022.07.22 |