- Home /
How do You Scale a Character/Object up and down?
Basically i want to have my character slightly scale up and down at some speed.
I'm reading stuff about localScale but just nobody has clear examples.
I just want to scale up and down.
This is not working and i dont understand why
using UnityEngine; using System.Collections;
public class BreathALive: $$anonymous$$onoBehaviour{ void start( ){
}
void update(){
transform.localScale += new Vector3( this.x + 0.1F, 0, 0);
}
}
Answer by Musabbir · Jul 21, 2018 at 10:39 AM
float speed = 3f;
float depth = 1f;
void Uodate(){
float scaleInOut = Mathf.Sin(Time.time * speed);
transform.localScale = new Vector3(scaleInOut, scaleInOut, scaleInOut) * depth;
}
Answer by beayfergm · Aug 19, 2013 at 06:52 AM
Your code should be something like:
using UnityEngine;
public class BreathALive: MonoBehaviour
{
void Start( )
{
// Initializations here...
}
void Update()
{
// warn: the scale will grow constantly with no end
transform.localScale += new Vector3(0.1f, 0, 0);
}
}
Thanks alot. Well but your example was basically the same as the other thing i tried before and didn't work either.
Could it be the mac version 4.1.5 has bugs?
Cause people say transform.localScale works but hasn't worked for me and the script is attached to my character.
Your void start() says intializations here, but in my case i dont need any right?
wait, now it worked. mmm i wonder what i did wrong before?
i did the exact transform.localScale += new vector3(0.1f, 0, 0);
i did though put a capital F for the flotat ins$$anonymous$$d of a small f. could that have been the problem?