Hi,
I am trying to scale an object with reference to its parent’s position in z axis. its works when i use the transform.localScale += new vector3 … But it increases and decreses infinitely. So I tried using mathf.clamp to clamp the values. Its not working though. ANy tips on how to do it? the code goes like this:
public class flameController : MonoBehaviour
{
public GameObject player;
private float zVal, minVal = 1.0f, maxVal = 1.25f;
private Vector3 termVal;
void Update()
{
zVal = player.transform.position.z;
print (zVal);
termVal = new Vector3 (0, 0, Mathf.Clamp(transform.localScale.z, minVal, maxVal));
if (zVal >= 1.0f)
{
transform.localScale = termVal;
}
}
}
I dont think so… I need to know some logic to over come
transform.localScale += termVal; , which scales my object in z axis indefinitely. That is why i have used the clamp which fails my purpose now. the if condition acts just a trigger.
Yes I found it out and gave the actual values in x and y. Now is there any way that i scale it in z axis with reference to the parent object position.z ?