<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
		<id>https://wiki.nonip.net/index.php?action=history&amp;feed=atom&amp;title=Unity%2F3d%2Fcollider%2F%E8%B7%9D%E9%9B%A2%E3%81%AB%E3%82%88%E3%82%8B%E9%9F%B3%E9%87%8F%E5%A4%89%E6%9B%B4</id>
		<title>Unity/3d/collider/距離による音量変更 - 変更履歴</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.nonip.net/index.php?action=history&amp;feed=atom&amp;title=Unity%2F3d%2Fcollider%2F%E8%B7%9D%E9%9B%A2%E3%81%AB%E3%82%88%E3%82%8B%E9%9F%B3%E9%87%8F%E5%A4%89%E6%9B%B4"/>
		<link rel="alternate" type="text/html" href="https://wiki.nonip.net/index.php?title=Unity/3d/collider/%E8%B7%9D%E9%9B%A2%E3%81%AB%E3%82%88%E3%82%8B%E9%9F%B3%E9%87%8F%E5%A4%89%E6%9B%B4&amp;action=history"/>
		<updated>2026-04-19T00:38:25Z</updated>
		<subtitle>このウィキのこのページに関する変更履歴</subtitle>
		<generator>MediaWiki 1.24.2</generator>

	<entry>
		<id>https://wiki.nonip.net/index.php?title=Unity/3d/collider/%E8%B7%9D%E9%9B%A2%E3%81%AB%E3%82%88%E3%82%8B%E9%9F%B3%E9%87%8F%E5%A4%89%E6%9B%B4&amp;diff=15149&amp;oldid=prev</id>
		<title>Admin: /* サンプル */</title>
		<link rel="alternate" type="text/html" href="https://wiki.nonip.net/index.php?title=Unity/3d/collider/%E8%B7%9D%E9%9B%A2%E3%81%AB%E3%82%88%E3%82%8B%E9%9F%B3%E9%87%8F%E5%A4%89%E6%9B%B4&amp;diff=15149&amp;oldid=prev"/>
				<updated>2022-04-22T14:29:13Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;サンプル&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←前の版&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2022年4月22日 (金) 14:29時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;行1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;行1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==サンプル==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==サンプル==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;範囲内に入った際に、ある位置からの距離を測定する。&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;範囲内に入った際に、ある位置から離れると音量が下がる。&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Unity/3d/collider/距離]] [ｼｮｰﾄｶｯﾄ]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Unity/3d/collider/距離]] [ｼｮｰﾄｶｯﾄ]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>https://wiki.nonip.net/index.php?title=Unity/3d/collider/%E8%B7%9D%E9%9B%A2%E3%81%AB%E3%82%88%E3%82%8B%E9%9F%B3%E9%87%8F%E5%A4%89%E6%9B%B4&amp;diff=15148&amp;oldid=prev</id>
		<title>2022年4月22日 (金) 14:28にAdminによる</title>
		<link rel="alternate" type="text/html" href="https://wiki.nonip.net/index.php?title=Unity/3d/collider/%E8%B7%9D%E9%9B%A2%E3%81%AB%E3%82%88%E3%82%8B%E9%9F%B3%E9%87%8F%E5%A4%89%E6%9B%B4&amp;diff=15148&amp;oldid=prev"/>
				<updated>2022-04-22T14:28:55Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←前の版&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2022年4月22日 (金) 14:28時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;行1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;行1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==サンプル==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;範囲内に入った際に、ある位置からの距離を測定する。&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Unity/3d/collider/距離]] [ｼｮｰﾄｶｯﾄ]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;上記参考に、一部改変する。&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;using UnityEngine;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;using UnityEngine;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>https://wiki.nonip.net/index.php?title=Unity/3d/collider/%E8%B7%9D%E9%9B%A2%E3%81%AB%E3%82%88%E3%82%8B%E9%9F%B3%E9%87%8F%E5%A4%89%E6%9B%B4&amp;diff=15147&amp;oldid=prev</id>
		<title>Admin: ページの作成:「&lt;pre&gt; using UnityEngine; public class SphereBgmTrigger : MonoBehaviour {     [SerializeField] AudioSource audioSource;     float maxDistance = 0f;// radius + 操作キャ...」</title>
		<link rel="alternate" type="text/html" href="https://wiki.nonip.net/index.php?title=Unity/3d/collider/%E8%B7%9D%E9%9B%A2%E3%81%AB%E3%82%88%E3%82%8B%E9%9F%B3%E9%87%8F%E5%A4%89%E6%9B%B4&amp;diff=15147&amp;oldid=prev"/>
				<updated>2022-04-22T14:28:27Z</updated>
		
		<summary type="html">&lt;p&gt;ページの作成:「&amp;lt;pre&amp;gt; using UnityEngine; public class SphereBgmTrigger : MonoBehaviour {     [SerializeField] AudioSource audioSource;     float maxDistance = 0f;// radius + 操作キャ...」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
using UnityEngine;&lt;br /&gt;
public class SphereBgmTrigger : MonoBehaviour&lt;br /&gt;
{&lt;br /&gt;
    [SerializeField] AudioSource audioSource;&lt;br /&gt;
    float maxDistance = 0f;// radius + 操作キャラ半径&lt;br /&gt;
    float maxVolumeRadius = 1f; // この半径範囲はmaxVolume&lt;br /&gt;
    // 範囲内に入ったとき&lt;br /&gt;
    void OnTriggerEnter(Collider collider)&lt;br /&gt;
    {&lt;br /&gt;
        Debug.Log(&amp;quot;OnTriggerEnter&amp;quot;);&lt;br /&gt;
        audioSource.Play();&lt;br /&gt;
        audioSource.loop = true;&lt;br /&gt;
        audioSource.volume = 0f;&lt;br /&gt;
        maxDistance = GetComponent&amp;lt;SphereCollider&amp;gt;().radius;&lt;br /&gt;
        Debug.Log(&amp;quot;maxDistance=&amp;quot; + maxDistance);&lt;br /&gt;
    }&lt;br /&gt;
    // 範囲中のとき&lt;br /&gt;
    void OnTriggerStay(Collider collider)&lt;br /&gt;
    {&lt;br /&gt;
        Debug.Log(&amp;quot;OnCollisionStay collision.gameObject.name=&amp;quot; + collider.gameObject.name);&lt;br /&gt;
        if (collider.gameObject.name == &amp;quot;CharacterSphere&amp;quot;)&lt;br /&gt;
        {&lt;br /&gt;
            float distance = Vector3.Distance(transform.position, collider.gameObject.transform.position);&lt;br /&gt;
            distance -= collider.gameObject.GetComponent&amp;lt;SphereCollider&amp;gt;().radius;&lt;br /&gt;
            distance -= maxVolumeRadius;&lt;br /&gt;
            if (distance &amp;lt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                distance = 0;&lt;br /&gt;
            }&lt;br /&gt;
            Debug.Log(&amp;quot;distance=&amp;quot; + distance);&lt;br /&gt;
            float volume =  1 - (distance / (maxDistance - maxVolumeRadius));&lt;br /&gt;
            Debug.Log(&amp;quot;volume=&amp;quot; + volume);&lt;br /&gt;
            audioSource.volume = volume;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // 範囲から抜けたとき&lt;br /&gt;
    void OnTriggerExit(Collider collider)&lt;br /&gt;
    {&lt;br /&gt;
        audioSource.Stop();&lt;br /&gt;
        Debug.Log(&amp;quot;OnTriggerExit&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>