Hi all,
In another attempt to customise things further, I’d like to scale the Paddle object in the X axis when it meets certain criteria that aren’t important as per this discussion.
I’m printing out this.transforn.localScale and I’m registering changes but the paddle itself doesn’t change size (it DOES when I modify it manually in the transform component via the Inspector tab).
Vector3 paddleSize;
void Start () {
paddleSize = this.transform.localScale;
paddleSize += new Vector3 (20,20,20);
print (paddleSize);
I’m using crazy values just in case. As usual, I’ve read the Unity reference over at (https://docs.unity3d.com/ScriptReference/Transform-localScale.html) but I just can’t begin to guess what might be wrong with my code.
Also, am I doing it right by first defining what paddleSize is in void Start and THEN modifying its values or is that not the optimal way to set it up?
Cheers,
Carl
I guess you need to assign paddleSize back to you transform.localScale:
transform.localScale = paddleSize;
Also - do you need ‘this’ in front of the transform? Normally it can be ommitted. Actually it should be, since ‘this’ refers to the instance of your script, not the game object the script is assigned to.
Some expert could verify the above, just in case - I’m new to Unity myself… 
I believe “this” references the instance, I was curious myself as to how Unity handled it. I simply changed my code from Destroy(gameObject) to Destroy(this), and it still only destroyed the correct brick.
You can also condense the code to one line.
this.transform.localScale += new Vector3(1,0,0);
Be careful increasing the y transform as it might trigger your lose condition if you make it too big. 
It’s coming up with this error… That’s nonsense, right? The curly bracket is right there.
If I had to guess, that last } is for closing the public class Paddle : MonoBehavior{…}. Try putting another one lined up with the bracket under void Start().
Actually it’s not, the one for the Mono is way down at the bottom and the one seen in my snippet is part of Start. Not that I’m 100% relying on it but it highlights it and everything to show that they’re paired.
Can you post the full paddle class file then? This works for me:
void Start () { this.transform.localScale += new Vector3(1,0,0); }