How to hit ( smash things) with a car

Hi All!

I’m fairly new to Unity, but a somewhat expierenced 3D artist. I got this car, on a track in a city. It drives around fine and all, but now I want to be able to Hit objects. Other then just crashing into an immovable object, I’d like them to fall over / fly around. Let’s say a barrel, or something else without joints to start with… How do I go about this? I’ve tried to ffigure out how this was done in the Bootcamp Demo (Shooting barrels and stuff), but couldn’t make heads or tails from the gunscript…

I’m sure there must be an easy way, maybe even without scripting at all?

When this is set up, I would like to smash stuff. Crates for example. What is the best way to go about this? It could just be a simple animation, triggered on the moment of impact. But is there another, better way, inside Unity itself? Grouping all the segments of the crate, inc breaklines, to ungroup at the moment of impact, and let the forces at work decide wich trajectory these elements make?

If someone could help me out, or point me in the right direction, Much obliged!

Thomas

You mean like a crate that breaks into little bits? You could have a solid crate that calls an instantiate function to spawn a broken crate, then destroy the solid. May not be the most elegant, but suit your purpose.

Ok, I understand. That would be like the ungrouping the thing on the moment of impact. I’ll try it out…

But first I’m still at step 1, actually getting other objects to move by hitting them. Once I got that I can focus on the destroying them part. Yes, I know, I’m a n00b at unity… I do have scripting experience as well though, so I’m trying to learn the unity basics real fast…

If you just want to objects to react when your car hits them they need to have physics enabled. You can add a rigidbody to enable physics.

Take a look at http://unity3d.com/support/documentation/Manual/Physics.html

Unity doesn’t currently have any built in support for destructible objects/environments so things like destructible crates will have to be scripted. Like Tzvier said you can Destroy the initial crate and instantiate a prefab, or as you suggested play an animation on impact.

Alternatively you can make your crate out of multiple objects to begin with and let the physics engine take its course but it probably won’t produce very realistic results and isn’t very efficient.

Here’s a good example of destructible glass - http://forum.unity3d.com/threads/3967-Destructable-Objects-Glass

Yes Thanks! This is what I needed to get it going… I’ll look into it Just after I had my pepperoni pizza! Thanks again…