Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- //script to apply scaling over time based on a curve
- //Quentin Preik - 2012/10/22
- //@fivearchers
- public class CurveScale : MonoBehaviour {
- public AnimationCurve scaleCurve; //Curve to scale with - usually cover 0 to 1 on both axis
- public Vector3 movement; //this is the scaling amount - it is additive, so if you say 0,2,0 - at 1 on the curve
- // your object would be 2x as big on the Y axis, and the same size on x and z
- public float scaleRate; //How fast to scale: 1=1s, 2=0.5s, 0.5=2s
- public float curvePos; //Use this as an offset, so at 0.5 it would start halfway thru the curve
- public bool loop=true; //Whether to loop or not
- Vector3 localstart;
- void Start () {
- localstart=transform.localScale;
- }
- void Update () {
- if (curvePos!=1||!loop){
- curvePos+=scaleRate*Time.deltaTime;
- if (curvePos>1f){curvePos=curvePos-1f;}
- transform.localScale=localstart+movement*scaleCurve.Evaluate(curvePos);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement