Hi there,
I attached the shake position script to a object, but find that the object shakes quite fast. I want to make it moves like slower swing. How could I change the speed (frequency) of the shake? Thanks so much!
Lee
Hi there,
I attached the shake position script to a object, but find that the object shakes quite fast. I want to make it moves like slower swing. How could I change the speed (frequency) of the shake? Thanks so much!
Lee
bump
bump
Just for your interest,
i made a little script for my own needs, moving some cloud sprites in a random way, using iTween :
float shakeAmplitude = 0.3f;
float shakeFrequency = 5f;
Vector3 originPosition;
void Start()
{
originPosition = transform.position;
InvokeRepeating("NewRandomPosition", 0f, shakeFrequency);
}
void NewRandomPosition()
{
Vector3 newPosition = originPosition + (Random.insideUnitSphere * shakeAmplitude);
iTween.MoveTo(gameObject, iTween.Hash(
"delay", Random.Range(0, shakeFrequency),
"position", newPosition,
"time", shakeFrequency,
"easetype", iTween.EaseType.easeInOutSine
));
}