I'm getting the error:
The name 'origScale' does not exist in the current context
This is the full script
public class HealthCollectible : MonoBehaviour
{
public float frequency = 1.3f;
public float amplitude = 0.1f;
public void Start() {
Vector3 origScale = transform.localScale;
}
public void Update() {
float sinWaveValue = Mathf.Sin(Mathf.PI * Time.fixedTime * frequency) * amplitude;
Vector3 scaleChange = new Vector3 (sinWaveValue, sinWaveValue, 0);
transform.localScale = origScale + scaleChange;
}
}
,I'm trying to using a Sin wave to adjust the scale of a game object.
But I'm getting the error,
The name 'origScale' does not exist in the current context
This is the full script.
public class HealthCollectible : MonoBehaviour
{
public float frequency = 1.3f;
public float amplitude = 0.1f;
public void Start() {
Vector3 origScale = transform.localScale;
}
public void Update() {
float sinWaveValue = Mathf.Sin(Mathf.PI*Time.fixedTime*frequency)*amplitude;
Vector3 scaleChange = new Vector3(sinWaveValue, sinWaveValue, 0);
transform.localScale = origScale + scaleChange;
}
↧