using UnityEngine;
using System.Collections;
public class ExplosionPhysics : MonoBehaviour {
public Vector3 Increment;
public Vector3 maxSize;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
transform.localScale += Increment * Time.deltaTime;
if(transform.localScale == maxSize)
{
Destroy(this.gameObject);
}
}
}
And,
using UnityEngine;
using System.Collections;
public class ExplosionPhysics : MonoBehaviour {
public Vector3 Increment;
public Vector3 maxSize;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
transform.localScale += Increment * Time.deltaTime;
if(transform.localScale >= maxSize)
{
Destroy(this.gameObject);
}
}
}
The part in question is the:
if(transform.localScale == maxSize)
{
Destroy(this.gameObject);
}
And,
if(transform.localScale >= maxSize)
{
Destroy(this.gameObject);
}
maxSize is equal to 15 on the x, y and z.
I need to have the transform.localScale >= maxSize however the only thing that will work is to have it == maxSize. However it skips over 15 exactly, probably because Time.deltaTime is a float. How can I rewrite this code so that I can check if the current scale is >= to another scale.