خرید بک لینک

Vote count: 0

I found this camera follow script on line for unity

public float dampTime = 0.15f;
private Vector3 velocity = Vector3.zero;
public Transform target;

public void TrackPlayer()
{
    //How is this possible?
    if (target)
    {
        Vector3 point = Camera.main.WorldToViewportPoint(target.position);
        Vector3 delta = target.position - Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, point.z)); //(new Vector3(0.5, 0.5, point.z));
        Vector3 destination = transform.position + delta;
        transform.position = Vector3.SmoothDamp(transform.position, destination, ref velocity, dampTime);
    }
}

I noticed that they use the transform directly in the if statement. This is perplexing, how can you do this in c#, I checked the inheritance chain and its not like they're inheriting from bool anywhere.

However when I try to check the watch window to see if target == true, I get a bizarre error Node not supported target == true.

How is this possibly, and why can't I check if the target == true?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 12 خرداد 1395 ساعت: 9:51

صفحه بندی