- Home /
Problem with Vectrosity line colliders
I've drawn some Vectrosity lines and have added colliders to them:
VectorLine line = new VectorLine("mirror" + mirrors.Count + 1, new Vector3[] { mirrorStart, mirrorEnd }, parameters.Material, parameters.Width);
line.collider = true;
I then attempt to detect collisions with them using Physics2D.Raycast.
RaycastHit2D hit = Physics2D.Raycast (startPoint, direction, Mathf.Infinity, layerMask);
Collider2D collider = hit.collider;
I then use the collider to work out which (if any) object or line was hit. This works fine when running in the editor and also on the Nexus 4. However, when running on the Nexus 7, the raycast does not seem to hit any of the Vectrosity lines, passing straight through them instead. Everything else renders as I'd expect on the Nexus 7, despite the different screen resolution. This lack of collisions is the only discrepency I'm seeing when running on this device but I can't figure out what's causing it. Any ideas?
EDIT: As a test, I condensed the problem down into a single script and the same thing is happening. The script first creates a vertical line with a collider. Then, on each frame, a horizonal raycast is performed and a second line is drawn from an arbitrary start point to the collision point. In the editor and on the Nexus 4, the second line meets the first at a right-angle and stops. On the Nexus 7, however, the second line passes straight through. Here is the complete script:
using UnityEngine;
using System.Collections;
using Vectrosity;
public class TestScript : MonoBehaviour {
VectorLine line = null;
VectorLine secondLine = null;
// Use this for initialization
void Start () {
Vector3 start = new Vector3 (0, 1);
Vector3 end = new Vector3 (0, 3);
line = new VectorLine("Bob", new Vector3[] { start, end }, null, 5);
line.collider = true;
line.Draw ();
}
// Update is called once per frame
void Update () {
Vector3 secondStart = new Vector3 (-1, 2);
RaycastHit2D hit = Physics2D.Raycast (secondStart, Vector3.right);
if (secondLine == null) {
secondLine = new VectorLine ("Fred", new Vector3[] { secondStart, hit.point }, null, 5);
} else {
secondLine.points3[0] = secondStart;
secondLine.points3[1] = hit.point;
}
secondLine.Draw ();
}
}
This is what I see in the editor and on the Nexus 4:
And here's what I see on the Nexus 7:
What could be causing this?