ボスの攻撃を作るその1(巨大ビーム砲)
巨大ビーム砲
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossShotBeam : MonoBehaviour
{
public GameObject bossBeamPrefab;
public AudioClip sound;
public float area;
public int shotInterval;
private int count;
private GameObject target;
void Start()
{
target = GameObject.Find("Player");
}
void Update()
{
if(Vector3.Distance(transform.position, target.transform.position) < area)
{
transform.LookAt(target.transform);
count += 1;
if(count % shotInterval == 0)
{
GameObject bossBeam = Instantiate(bossBeamPrefab, transform.position, transform.rotation);
Destroy(bossBeam, 5.0f);
AudioSource.PlayClipAtPoint(sound, transform.position);
}
}
}
}
【2019版】X_Mission(基礎/全51回)
他のコースを見る巨大ビーム砲
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossShotBeam : MonoBehaviour
{
public GameObject bossBeamPrefab;
public AudioClip sound;
public float area;
public int shotInterval;
private int count;
private GameObject target;
void Start()
{
target = GameObject.Find("Player");
}
void Update()
{
if(Vector3.Distance(transform.position, target.transform.position) < area)
{
transform.LookAt(target.transform);
count += 1;
if(count % shotInterval == 0)
{
GameObject bossBeam = Instantiate(bossBeamPrefab, transform.position, transform.rotation);
Destroy(bossBeam, 5.0f);
AudioSource.PlayClipAtPoint(sound, transform.position);
}
}
}
}
ボスの攻撃を作るその1(巨大ビーム砲)