[SOLVED] Limit Max scale and Min Scale on Scaling

Random discussions.

[SOLVED] Limit Max scale and Min Scale on Scaling

Postby sergi » Tue Apr 12, 2016 12:54 pm

Hi,

I need to limit max and Min scale when object has transformGesture with Scale,Rotate translate

Thansk you
Last edited by sergi on Mon May 09, 2016 6:24 pm, edited 1 time in total.
sergi
 
Posts: 33
Joined: Mon Mar 02, 2015 3:17 pm

Re: Limit Max scale and Min Scale on Scaling

Postby valyard » Wed Apr 13, 2016 3:38 pm

For this you need to either extend Transformer component or write a new one.
Transformer component takes events from TransformGesture and applies changes to GameObject. You can add your constraints there in the code.
valyard
Site Admin
 
Posts: 433
Joined: Mon Sep 08, 2014 11:57 pm

Re: Limit Max scale and Min Scale on Scaling

Postby sergi » Mon May 09, 2016 6:14 pm

Thanks.

I modify the TransformGesture Component.

Code: Select all
 public void ApplyTransform(Transform target)
        {
         // solo escalamos si estamos dentro del rango max y min.
         if (!Mathf.Approximately (DeltaScale, 1f)) {            
            Vector3 aux = target.localScale * DeltaScale;
            //debug.text = (aux.x).ToString();
            if ((aux.x > 0.4f) && (aux.x < 3.91f)) target.localScale *= DeltaScale;
         }
            if (!Mathf.Approximately(DeltaRotation, 0f)) target.rotation = Quaternion.AngleAxis(DeltaRotation, RotationAxis) * target.rotation;
            if (DeltaPosition != Vector3.zero) target.position += DeltaPosition;
        }


Now only scale between 0.4f and 3.91f !
sergi
 
Posts: 33
Joined: Mon Mar 02, 2015 3:17 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest