mirror of
https://github.com/DerTyp7/traffic-unity.git
synced 2025-10-30 13:17:08 +01:00
place streets
This commit is contained in:
31
Assets/Scripts/PlaceableObjectChild.cs
Normal file
31
Assets/Scripts/PlaceableObjectChild.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class PlaceableObjectChild : MonoBehaviour
|
||||
{
|
||||
|
||||
public bool placeable = true;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
transform.localPosition = new Vector3(0.5f, 0f, 0f);
|
||||
if (placeable)
|
||||
{
|
||||
GetComponent<SpriteRenderer>().color = Color.blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetComponent<SpriteRenderer>().color = Color.red;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionStay2D(Collision2D collision)
|
||||
{
|
||||
placeable = false;
|
||||
|
||||
}
|
||||
|
||||
private void OnCollisionExit2D(Collision2D collision)
|
||||
{
|
||||
placeable = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user