I want to ask you something, how can i make a part of my uh… thing, fall off, when enough force is applied (Yes, i made it in several parts, and connected 'em) Im trying to make a battlebots game, where if you bash the other enemy hard enough, the part attacked will fall off. so… force = Detachment. how.
Bump. Indeed.
Each part could have
BotPart.js
var isAttacking : boolean = false;
function OnCollisionEnter( c : Collision ) {
if ( isAttacking ) {
var part : BotPart = c.collider.GetComponent(BotPart);
if ( part ) {
part.HitWithForce( rigidbody.velocity );
}
}
}
function HitWithForce( force : Vector3 ) {
if ( force.magnitude > strength ) {
transform.parent = null;
rigidbody.velocity = force * .5;
}
}
Then your parts would need rigidbodies and be set to ignore collisions with other parts of the same bot either through physics layers or Physics.IgnoreCollision.