Silver-like movement

I’m trying to make Angry Birds in unity, and I got everything else working as intended, including the birds: Red,
Hal, Chuck, Blues and Terence. But 1 bird has been stumping me, Silver, from Angry Birds 2. For those who don’t know, Silver has increased power to stone, with the ability to loop-de-loop then crash down, slightly popping nearby blocks and pigs into the air. The “pop into the air” part is not my main concern, how in the heck am I supposed to do a full on loop-de-loop!? I have tried countless things and failed.

So far my code for when Silver’s power is activated looks something like this:

        if (P)
        {
            if (//Hal's power script)
            else if (B == 4)
            {
                if (idk == 0 && !(transform.position.y < cm.y))
                {
                    idk = 1;
                }
                else if (transform.position.y < cm.y && idk == 0)
                {
                    ca += -1 * Time.deltaTime;
                    Vector2 offset = new Vector2(Mathf.Sin(ca), Mathf.Cos(ca));
                    transform.position = cm + offset;
                }
                if(idk == 1 && !(transform.position.y > cm.y))
                {
                    idk = 2;
                }
                else if (transform.position.y > cm.y && idk == 1)
                {
                    ca += -1 * Time.deltaTime;
                    Vector2 offset = new Vector2(Mathf.Sin(ca), Mathf.Cos(ca));
                    transform.position = cm + offset;
                }
                if (idk == 2)
                {
                    P = false;
                    rb.velocity = Vector2.down * 10;
                }
            }
        }

cm is the center movement pont determined right when the power is activated. Also this is all in void Update(). Any and all help on this (and maybe on any other bird I didn’t mention at the start) would be greatly appreciated!

I’m guessing it might be a canned final animation.

If you post a link to a video (with timestamp) showing the effect in question, perhaps we can comment further.

I don’t exactly know how to do that, but I can tell you what happens. The problem here is she ends up starting the loop about 3/4 through. I also want to make sure that her collider follows her so that crashing during the loop ends the loop, so just having an animation of the loop is non-viable. How do I start from a certain point in the loop? If there is any ambiguity about exactly what I want to do, try playing Angry Birds 2 to see for yourself.

I’m not the OP, but here’s a video of that particular bird in action:

Looks like when you tap the screen, the bird flies in a counter-clockwise semicircle before slamming downwards.

Yep, that’s Silver alright. Question is, how do I recreate that in unity?

Good question! I love this sort of code-driven animation… so… please enjoy the enclosed package!

This is the meat-and-potatoes script here, but the package includes a fully-set-up scene with test instrumentation.

https://gist.github.com/kurtdekker/97920f90e31f66c4c60626011cd2014b

7960887–1020357–SilverLooper.unitypackage (48.1 KB)

Yep, few tweeks, she’s working! Thanks!

1 Like