<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Building Colliders]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=490</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=490&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Building Colliders.]]></description>
		<lastBuildDate>Thu, 06 Apr 2017 13:01:06 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Building Colliders]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2159#p2159</link>
			<description><![CDATA[<p>You can check if bounds.min and bounds.max are within your sphere, then the entire collider inside the sphere.<br /><a href="https://docs.unity3d.com/ScriptReference/Bounds.html">https://docs.unity3d.com/ScriptReference/Bounds.html</a></p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 06 Apr 2017 13:01:06 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2159#p2159</guid>
		</item>
		<item>
			<title><![CDATA[Re: Building Colliders]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2155#p2155</link>
			<description><![CDATA[<p>My OverlapSphere was too small given the scale of the other geometry. RayCasts were detecting the colliders for the buildings, but an OverlapSphere on the surface of the map wasn&#039;t hitting the walls or roof of the building mesh. Looks like I can use OverlapCapsule instead, with the radius being the same, but scaling the height way up so it&#039;s sure to intersect the roof.</p><p>Is there a call similar to OverlapSphere that will instead tell you if the sphere is inside a collider instead of just when it&#039;s intersecting one of its edges?</p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Wed, 05 Apr 2017 16:53:09 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2155#p2155</guid>
		</item>
		<item>
			<title><![CDATA[Re: Building Colliders]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2147#p2147</link>
			<description><![CDATA[<p>Okay, thanks. I&#039;ll figure it out and, if it&#039;s something I think others might run into, I&#039;ll post about it here.</p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Tue, 04 Apr 2017 01:14:33 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2147#p2147</guid>
		</item>
		<item>
			<title><![CDATA[Re: Building Colliders]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2146#p2146</link>
			<description><![CDATA[<p>In general, it looks well.<br />But I did not test your code, so I can not say exactly.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 03 Apr 2017 22:54:56 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2146#p2146</guid>
		</item>
		<item>
			<title><![CDATA[Re: Building Colliders]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2145#p2145</link>
			<description><![CDATA[<p>Awesome, thanks!</p><p>I guess there are no obvious bugs in the code I pasted?</p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Mon, 03 Apr 2017 20:57:23 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2145#p2145</guid>
		</item>
		<item>
			<title><![CDATA[Re: Building Colliders]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2144#p2144</link>
			<description><![CDATA[<p>Hello.</p><p>Example of how to change a layer of buildings:<br /></p><div class="codebox"><pre><code>using UnityEngine;

public class ChangeLayerOfBuilding:MonoBehaviour
{
    public int buildingLayer = 8;

    private void Start()
    {
        OnlineMapsBuildings.instance.OnBuildingCreated += OnBuildingCreated;
    }

    private void OnBuildingCreated(OnlineMapsBuildingBase building)
    {
        building.gameObject.layer = buildingLayer;
    }
}</code></pre></div><p>Yes, I think the ability to specify a layer of buildings is useful, and we will implement it in the next version.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 03 Apr 2017 20:40:08 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2144#p2144</guid>
		</item>
		<item>
			<title><![CDATA[Building Colliders]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2139#p2139</link>
			<description><![CDATA[<p>I&#039;m having trouble detecting the colliders attached to buildings on the map. I want to avoid them when I spawn gameobjects. Here&#039;re the relevant procedures:</p><div class="codebox"><pre><code>    public Vector3 CoordsToPosition(Vector2 coords)
    {
        m_map.GetCorners(out m_tlx, out m_tly, out m_brx, out m_bry);
        Vector3 world_pos = m_tileset.GetWorldPositionWithElevation(coords, m_tlx, m_tly, m_brx, m_bry);
        return world_pos;

    }

    public void SmartSpawnGameObject(GameObject prefab, Vector2 map_coords)
    {

        m_coords = map_coords;
        m_prefab = prefab;
        Vector3 world_pos = CoordsToPosition(m_coords);

        Collider[] overlaps = Physics.OverlapSphere(world_pos, m_spawn_size);
        foreach (Collider hit in overlaps)
        {
            Debug.Log(hit.gameObject.name);
        }
        // If there are no colliders in the area the unit will spawn...
        if (overlaps.Length &lt; 2)
            Instantiate(prefab, world_pos, Quaternion.identity);
        else
        // Note that we&#039;ve got to iterate through a spiral of potential spawnpoints
        {
            m_waitspawn = true;
        }
    }</code></pre></div><p>Right now all I&#039;m getting back is the Tileset&#039;s collider. I check to see if there&#039;s more than one collider since right now I can&#039;t mask the Tileset from the OverlapSphere check.</p><p>Also, for when I get that sorted, is there a relatively easy way to put the buildings on a separate layer from the map? As it stands all buildings inherit the map&#039;s layer, and since there&#039;s no prefab for the buildings, it doesn&#039;t seem to be able to be specified ahead of time. Might be a good public property to add to the Buildings component.</p><p>Since you helped me with the code to determine when all the buildings have been created, I can go in after that and find them all and set the layer that way, but thought I&#039;d ask in case there were a more elegant solution that didn&#039;t require changing the code in your component.</p><p>Thanks!</p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Mon, 03 Apr 2017 19:07:22 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2139#p2139</guid>
		</item>
	</channel>
</rss>
