mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-16 21:08:28 +00:00
Change Camera.current to Camera.main to avoid OutOfRangeDestroyer from
grabbing scene camera
This commit is contained in:
parent
b1f7854d48
commit
1e378b4d9c
1 changed files with 7 additions and 9 deletions
|
@ -8,28 +8,26 @@ public class OutOfRangeDestroyer : MonoBehaviour
|
|||
|
||||
private float timeSinceOutOfRange = 0;
|
||||
|
||||
// Use this for initialization
|
||||
private void Start()
|
||||
{
|
||||
if (null == targetObject)
|
||||
if (targetObject == null)
|
||||
{
|
||||
if (Camera.current != null)
|
||||
targetObject = Camera.current.transform;
|
||||
if (Camera.main != null)
|
||||
targetObject = Camera.main.transform;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
timeSinceOutOfRange += Time.deltaTime;
|
||||
|
||||
if (null == targetObject)
|
||||
if (targetObject == null)
|
||||
{
|
||||
if (Camera.current != null)
|
||||
targetObject = Camera.current.transform;
|
||||
if (Camera.main != null)
|
||||
targetObject = Camera.main.transform;
|
||||
}
|
||||
|
||||
if (null != targetObject)
|
||||
if (targetObject != null)
|
||||
{
|
||||
float distanceSq = (transform.position - targetObject.position).sqrMagnitude;
|
||||
if (distanceSq <= range * range)
|
||||
|
|
Loading…
Add table
Reference in a new issue