Hey, guys. I was wondering if anyone could help me get around this issue. The logical leap just isn’t forming for me, here. I’m attempting to scale on object up over its lifetime, using the Update() function. I want to go from scale 1 to scale 5, over the course of objectLife. Here’s my incorrect code:
if(transform.localScale.x < 5)
{
transform.localScale = transform.localScale + (4f / objectLife) * Time.deltaTime;
}
The problem here is apparent in the first line. I have to use .x, because you can’t say, localScale < 5f, as it’s a Vector3. This is the same issue that occurs in the if statement’s functionality, i.e. you can’t add a float value to it. You ALSO, however, can’t add a float value to separate floats in the vector, such as:
transform.localScale.x = transform.localScale.x + (4f / objectLife) * Time.deltaTime;
They are read-only, though for what reason I can’t surmise. What can I do to circumvent this issue? As I said, the math just isn’t coming to me.