- Home /
Non-coding question. How would I achieve this effect?
The Setup: The Player can jump very high in the air and when they land, it smashes anything below them. I have a test vehicle in the scene equipped with a MeshDeformer script so the Player can land anywhere on the car and it will appear dented/smashed. The vehicle cannot have a RigidBody on it due to the MeshDeformer not using Convex. When the car gets crumpled up, the script then resets the MeshCollider to form the car's new shape.
What I want: The Player to be able to jump on the car/crush it and have the ability to throw the car.
The problem: Without the ability to smoothly add a RigidBody/Convex, I just don't see a way to achieve the Player being able to throw the vehicle. I know I can swap prefabs of a broken car in and out, but it wouldn't look correct if the Player lands on the hood or trunk, and suddenly the ceiling is caved in because of how the smashed car prefab looks. I can't separate the two either, meaning put a child GameObject with a BoxCollider and RigidBody on the vehicle because the BoxCollider would have to be roughly the same size of the car and hence the Player would never make contact/smash the MeshCollider under it. I could try disabling the MeshDeformer script upon pickup and then adding in the RigidBody, but that might get a little messy since I would also have to turn it off the moment it stopped moving? I don't know. Does anyone have any ideas on how I can achieve this? Thank you.
Answer by Owen-Reynolds · May 23, 2021 at 02:03 AM
I suppose adding compound colliders (lots of small cube or sphere collider children) would make it throwable and allow you to fake concavity by shrinking only certain ones. Maybe a sphere-cast (which is more programming) could find which colliders need to shrink as it was stomped on. The math doesn't seem easy (but I've never used your Mesh Deformer, so not sure what help it could give. You may be able to attach colliders to each bone).