Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

The name 'origScale' does not exist in the current context

$
0
0
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; }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>