Hi everyone, I have to create a simulation of roller blinds controlled by a remote.
To do that I tried to use Itween. I don’t really know much things about this program. Actually I was able to move the objects with MoveTo but I could’nt scale it with the function Scaleto. Here is what i have :
using UnityEngine;
using System.Collections;
public class ShutterController : MonoBehaviour {
public string keyPress = "1";
public bool startUp = true;
public float upHeight = 2f;
public float downHeight = 0f;
public float speed = 1f;
public float upScale = 2f;
public float downScale = 0f;
private bool lastMoveWasUp;
void Start () {
if (startUp) {
// si le volet est en position haute de depart, le bouger vers la position haute.
transform.localPosition = new Vector3 (transform.localPosition.x, upHeight, transform.localPosition.z);
lastMoveWasUp = true;
// scale position fine
transform.localScale = new Vector3 (transform.localPosition.x, upScale, transform.localScale.z);
} else {
//si le volet est en position basse au depart, le bouger vers la position basse.
transform.localPosition = new Vector3 (transform.localPosition.x, downHeight, transform.localPosition.z);
lastMoveWasUp = false;
//scale position large
transform.localScale = new Vector3 (transform.localPosition.x, downScale, transform.localScale.z);
}
}
void Update () {
if (Input.GetKeyDown(keyPress)) {
Toggle();
}
}
void Toggle () {
if (lastMoveWasUp){
//si le dernier mouvmement remontait vers le haut, descendre vers positon basse.
iTween.MoveTo (gameObject, iTween.Hash ("position", new Vector3 (transform.localPosition.x, downHeight, transform.localPosition.z), "speed", speed, "easetype", "linear"));
lastMoveWasUp = false;
// scale position large
iTween.ScaleTo (gameObject, iTween.Hash ("scale", new Vector3 (transform.localPosition.x, downScale, transform.localPosition.z), "speed", speed, "easetype", "linear"));
} else {
// si le dernier mouvement descendait vers le bas, remonter en position haute.
iTween.MoveTo (gameObject, iTween.Hash ("position", new Vector3 (transform.localPosition.x, upHeight, transform.localPosition.z), "speed", speed, "easetype", "linear"));
lastMoveWasUp = true;
// scale position fine
iTween.ScaleTo (gameObject, iTween.Hash ("scale", new Vector3 (transform.localPosition.x, upScale, transform.localPosition.z), "speed", speed, "easetype", "linear"));
}
}
}
The translation works fine, but the scale doesn’t. Does anyone have a solution ? Also i have got another question, what is the difference between :
ITween.Moveto (“scale”)
ITwen.Scaleto (“scale”)
Thank you so much