I have such a code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LookingPlayer : MonoBehaviour {
public GameObject Player;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Physics.Linecast(this.transform.position, Player.transform.position))
Debug.Log("blocked");
Debug.DrawLine (this.transform.position, Player.transform.position);
}
}
The line is drawn just fine, but the funcion Linecast() doesn’t return false.
Each object has a BoxCollider2d, so I can’t understand why linecast doesn’t return false, since there is an obstacle(black wall) between two objects