Unity animation spiral effect
Let´s go! Using your unity engine create a new game object to your scene. I will call "myGameObject".
Add to game object a sprite render with any sprite:
Now, create a new C# script, I called him "SpiralAnim.cs".
At vars declaration put:
float timeCounter = 0;
float speed;
float width;
float height;
float deep;
In your Start() method put:
speed = 3;
width = 6;
height = 3;
deep = 50;
In your Update() method put:
if(this.GetComponent<SpriteRenderer>().enabled == false)
{
this.GetComponent<SpriteRenderer>().enabled = true;
}
if (transform.localScale.x>0)
{
timeCounter += Time.deltaTime * speed;
float x = Mathf.Cos(timeCounter) * width;
float y = Mathf.Sin(timeCounter) * height;
float z = timeCounter * deep;
transform.position = new Vector3(x, y, 0);
transform.localScale -= new Vector3(0.01f, 0.01f, 0);
transform.rotation = Quaternion.Euler(0, 0, z);
}
else
{
Destroy(this.gameObject);
}
And to finish, add the script to your game object, run the scene and see the final result.
Tip: change the values of variables: speed, width, height and deep until custom to your need.
If you prefer can see our full game in: https://play.google.com/store/apps/details?id=com.littlebeegames.divertholes, and tell us what tutorial we can talk in our next post. See you later!
Divert holes
Solve all the puzzles! Welcome to the world of Divert holes!
Status | Released |
Author | littlebeegames |
Genre | Puzzle |
Tags | android, brain, car, logic |
Languages | English, Portuguese (Portugal) |
Leave a comment
Log in with itch.io to leave a comment.