Failed attempt at conquering my first level

I’m not a skilled rocket pilot yet!

4 Likes

Cool rocket. I like that it falling apart after hit. Two questions:

  1. You made rocket in unity?
  2. How You made destruction effect?
    Regards!
1 Like

Thanks!

  1. No, I made the rocket in blender, I have used it some in the past and found it interesting to see how it worked together with unity. The thing I spent the most time on is the fins, but most of my effort there isn’t really visible in the game so I could’ve made it a whole lot simpler. I used an image of a V2 rocket as a reference, and stylized it a bit in the end.
  2. For this I took my rocket and made a modified version of it that I split apart in more pieces, and every piece has a rigidbody and a mesh collider with the convex box ticked off. When the rocket hits something I replace it with this modified version and adds an explosion force to all the parts.

My explode method:

private void Explode(Collision collision)
{
    var brokenRocket = Instantiate(pieces, transform.position, transform.rotation);
    var parts = brokenRocket.GetComponentsInChildren<Rigidbody>();
    var explosionForce = collision.impulse.magnitude * 15;
    Destroy(gameObject);

    foreach (var part in parts)
    {
        part.AddExplosionForce(explosionForce, collision.contacts.First().point, 30f, 2f);
    }
}

i call it in OnCollisionEnter

private void OnCollisionEnter(Collision collision)
{
    switch (collision.gameObject.tag)
    {
        case Tags.Friendly:
            // Do Nothing
                break;
        default:
            Explode(collision);
            break;
    }
}

The pieces variable is a GameObject field with the SerializeField attribute:

[SerializeField]
GameObject pieces;

I put the modified rocket into this field in the editor:

I was inspired by this tutorial on how to do parts of it, they use javascript in the tutorial but it’s pretty easy to translate into C#.

I see that I have a bug in this that OnCollisionEnter is triggered several times which causes several modified rockets to be instantiated, but that kind of adds to the effect so I’m not sure I will fix it…

The fins are a nice touch to the rocket. The object damage is a very cool idea for an effect. It would be neat to see in other ways in your game as well.

1 Like

The fins are nice, a little too nice is what I mean as I spent too long trying to make them as similar to the V2 rocket fins as I managed, but no one would see the difference in the game…

Yeah, would be cool to have some more destructibles in the game eventually.

Thanks for reply, I will try to implement it to my project. I dont have skill in blender, but maybe i will create more complicated rocket, and Ill try Your explosion effect. I will share it when its done, it can take few days, because I don`t have much time now… :frowning:
Regards! :slight_smile:

1 Like

Blender is not necessary at all, I just did it that way to try it out. Feel free to ask me if I can help with anything! :slight_smile:

Thanks :slight_smile: And have a nice day!

That is so cool!

1 Like

Privacy & Terms