- Home /
transform.localscale suddenly stopped working!,transform.localscale not working!!!
I made a script to gradually decrease the scale of a sphere over time and it worked perfectly fine but all of a sudden it stopped working after I made my UI for the game. The UI or any canvas has nothing to do with the sphere, the sphere was left untouched. Here is the script:
public class PassSphere: MonoBehaviour
{
public bool decSize = false;
private GameController gameController;
private void Start()
{
gameController = GameObject.Find("Game Controller").GetComponent<GameController>();
}
private void Update()
{
Debug.Log("Working");
Vector3 scale = Vector3.Lerp(gameObject.transform.localScale, Vector3.zero,gameController.sphereSizeReduceRate * Time.deltaTime);
gameObject.transform.localScale = scale;
}
private void OnTriggerEnter(Collider other)
{
gameController.IncreaseHighScore(transform.localScale.x);
gameController.ResetHealth();
}
private void OnTriggerExit(Collider other)
{
Destroy(gameObject);
}
}
The astonishing thing is the everything else is working in the update method, the debug statement also gets updated in the console. There are absolutely no animations on the sphere. The components are: 1)Mesh Filter 2)Mesh Renderer 3)Box Collider 4)This script 5)another script which controls a text box on top of the sphere which was also working before it has nothing to do with the sphere size control. I have looked around everywhere couldn't find an answer to this everything in the script is working just not the transform.localscale which was working before I made the UI!!! what happened!?
Answer by PryorG · Apr 04 at 10:05 AM
Did you ever find a solution to this? I am having this issue currently. @somehalaldev79
Your answer
Follow this Question
Related Questions
Resize object forward instead of along the z axis 4 Answers
What is the reasoning of multiplying by Time.deltaTime 1 Answer
transform.localScale unexpected behavior after Rotate() 1 Answer
How to make an object's localscale values grow and shrink within a few seconds? 0 Answers
I have a transform problem and I really don't know why 2 Answers