Topic: Collision between markers

Hello,
I want to make 2 markers collide between them when one move close enough to the other.
But when the moving marker move, the collider don't follow and stay at the origin point. I use boxcollider2D.

Since it's not possible to my knowledge to use sprite on the map (they are created "under" the map), this is the only way I find to have moving elements on my map, maybe it's not the best way to do that ?

Thanks for help

Re: Collision between markers

Hello.

Your question looks very simple, but, unfortunately, I did not understand anything, except that you want to detect the collision markers.
What control do you use?
You use built-in or your own marker system?
What should happen when the markers are collided?
You just want to detect the collision, or to make the markers do not intersect?

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Collision between markers

Sorry english is not my native language ...
I use GUI Texture Control, with the built-in marker system.
I just want to remove the marker when it collide, so I just want to detect the collision

Thank you for your fast response

Re: Collision between markers

When you use GUI Texture Control, markers drawn directly into map texture, so you can not use boxcollider2D.

Example of how to detect collision of markers (without the colliders):

using System.Linq;
using UnityEngine;

public class DetectMarkersCollision:MonoBehaviour
{
    private void Update()
    {
        CheckMarkersCollision();
    }

    private void CheckMarkersCollision()
    {
        OnlineMapsMarker[] markers = OnlineMaps.instance.markers;
        if (markers.Length < 2) return;

        Rect[] rects = markers.Select(m => m.screenRect).ToArray();

        for (int i = 0; i < rects.Length - 1; i++)
        {
            Rect rect1 = rects[i];
            for (int j = i + 1; j < rects.Length; j++)
            {
                Rect rect2 = rects[j];
                if (rect1.Overlaps(rect2)) OnCollisionDetected(markers[i], markers[j], i, j);
            }
        }
    }

    private void OnCollisionDetected(OnlineMapsMarker marker1, OnlineMapsMarker marker2, int index1, int index2)
    {
        Debug.Log("Collision detected between " + index1 + " and " + index2);
    }
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Collision between markers

I forgot to write:
Actually you can use boxcollider2D, but you need to update colliders position manually to make it work.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Collision between markers

Thank you i will try that.

Otherwise is there a controller who can draw markers apart from the map texture ?

Re: Collision between markers

Create your own marker system, for example using uGUI, and you'll have a separate markers and map.
Example:
http://infinity-code.com/atlas/online-m … ample.html

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.