ノーマルビームの作成(クラスの継承)
![Fb0a82c5 e31f 4d62 b54e 3d006fcbf677](https://codegenius.org/uploads/slide/image/8204/fb0a82c5-e31f-4d62-b54e-3d006fcbf677.jpeg)
![E562ef56 96cd 40b4 8b69 cdaf3113881f](https://codegenius.org/uploads/slide/image/8205/e562ef56-96cd-40b4-8b69-cdaf3113881f.jpeg)
ノーマルビーム弾
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NormalBeam : BeamBase // ★追加(クラス継承)
{
// ★(ポイント)「override」キーワードを必ず付けること。
public override void OnTriggerEnter(Collider other)
{
base.OnTriggerEnter(other);
// 触れた相手にRigidbodyが付いているか否かを判定する
if (other.attachedRigidbody)
{
// 押す機能
other.attachedRigidbody.AddForce(transform.forward * 500);
// 効果音
AudioSource.PlayClipAtPoint(Sound, Camera.main.transform.position);
}
}
}
![Be2a3ff8 1852 4b66 a0c5 0d84bd43a151](https://codegenius.org/uploads/slide/image/8206/be2a3ff8-1852-4b66-a0c5-0d84bd43a151.jpeg)
![E6f766d8 9bb6 4da8 8021 f92b7f09f4ba](https://codegenius.org/uploads/slide/image/8207/e6f766d8-9bb6-4da8-8021-f92b7f09f4ba.jpeg)
![Bdb38c62 7e2a 4f0e 8965 2719720ec695](https://codegenius.org/uploads/slide/image/8208/bdb38c62-7e2a-4f0e-8965-2719720ec695.jpeg)
![1464d160 3b39 45c3 b1a7 b4e8c63746a9](https://codegenius.org/uploads/slide/image/8209/1464d160-3b39-45c3-b1a7-b4e8c63746a9.jpeg)
【2021版】X_Mission(全34回)
他のコースを見る![Fb0a82c5 e31f 4d62 b54e 3d006fcbf677](https://codegenius.org/uploads/slide/image/8204/fb0a82c5-e31f-4d62-b54e-3d006fcbf677.jpeg)
![E562ef56 96cd 40b4 8b69 cdaf3113881f](https://codegenius.org/uploads/slide/image/8205/e562ef56-96cd-40b4-8b69-cdaf3113881f.jpeg)
ノーマルビーム弾
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NormalBeam : BeamBase // ★追加(クラス継承)
{
// ★(ポイント)「override」キーワードを必ず付けること。
public override void OnTriggerEnter(Collider other)
{
base.OnTriggerEnter(other);
// 触れた相手にRigidbodyが付いているか否かを判定する
if (other.attachedRigidbody)
{
// 押す機能
other.attachedRigidbody.AddForce(transform.forward * 500);
// 効果音
AudioSource.PlayClipAtPoint(Sound, Camera.main.transform.position);
}
}
}
![Be2a3ff8 1852 4b66 a0c5 0d84bd43a151](https://codegenius.org/uploads/slide/image/8206/be2a3ff8-1852-4b66-a0c5-0d84bd43a151.jpeg)
![E6f766d8 9bb6 4da8 8021 f92b7f09f4ba](https://codegenius.org/uploads/slide/image/8207/e6f766d8-9bb6-4da8-8021-f92b7f09f4ba.jpeg)
![Bdb38c62 7e2a 4f0e 8965 2719720ec695](https://codegenius.org/uploads/slide/image/8208/bdb38c62-7e2a-4f0e-8965-2719720ec695.jpeg)
![1464d160 3b39 45c3 b1a7 b4e8c63746a9](https://codegenius.org/uploads/slide/image/8209/1464d160-3b39-45c3-b1a7-b4e8c63746a9.jpeg)
ノーマルビームの作成(クラスの継承)