敵の攻撃の作成



EnemyShotBullet
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyShotBullet : MonoBehaviour {
public GameObject enemyBulletPrefab;
public float shotSpeed;
public AudioClip shotSound;
private int timeCount;
void Update () {
timeCount += 1;
// (復習)「%」と「==」の意味を復習しましょう!
if(timeCount % 60 == 0){
GameObject enemyBullet = (GameObject)Instantiate (enemyBulletPrefab, transform.position, Quaternion.Euler (transform.parent.eulerAngles.x, transform.parent.eulerAngles.y, 0));
Rigidbody enemyBulletRb = enemyBullet.GetComponent<Rigidbody> ();
enemyBulletRb.AddForce (transform.forward * shotSpeed);
AudioSource.PlayClipAtPoint (shotSound, Camera.main.transform.position);
Destroy (enemyBullet, 3.0f);
}
}
}





EscapeCombat(メモ)
他のコースを見る


EnemyShotBullet
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyShotBullet : MonoBehaviour {
public GameObject enemyBulletPrefab;
public float shotSpeed;
public AudioClip shotSound;
private int timeCount;
void Update () {
timeCount += 1;
// (復習)「%」と「==」の意味を復習しましょう!
if(timeCount % 60 == 0){
GameObject enemyBullet = (GameObject)Instantiate (enemyBulletPrefab, transform.position, Quaternion.Euler (transform.parent.eulerAngles.x, transform.parent.eulerAngles.y, 0));
Rigidbody enemyBulletRb = enemyBullet.GetComponent<Rigidbody> ();
enemyBulletRb.AddForce (transform.forward * shotSpeed);
AudioSource.PlayClipAtPoint (shotSound, Camera.main.transform.position);
Destroy (enemyBullet, 3.0f);
}
}
}





敵の攻撃の作成