FragMate CommunityLog in

FragMate - Software and Game Developer Community, including Resources, Forums, Marketplace & More.

Share

descriptionhowto destroy boxes only with force not just touch

more_horiz
i am making a Mario styled game, I wrote a script so if I jump and hit a box it destroys but if I walk on top of the boxes as soon as I touch the box it also gets destroyed,
any ideas on how to make it so the box doesn't get destroyed if I walk ontop of it. cheers

this is my destroy script

var XPos : float = transform.position.x;
var YPos : float = transform.position.y;
var ZPos : float = transform.position.z;
var Waiting : float = 0.02;

function OnTriggerEnter (col : Collider) {

if (col.gameObject.tag == "Player") {
this.transform.position = Vector3(XPos, YPos+0.1, ZPos);
yieldWaitForSeconds(Waiting);
this.transform.position = Vector3(XPos, YPos+0.2, ZPos);
yieldWaitForSeconds(Waiting);
transform.GetComponent.<Collider>().isTrigger = false;
this.transform.position = Vector3(XPos, YPos+0.3, ZPos+0.5);
yieldWaitForSeconds(Waiting);
this.transform.position = Vector3(XPos, YPos+0.4, ZPos+1.0);
yieldWaitForSeconds(Waiting);
this.transform.position = Vector3(XPos, YPos-0.1, ZPos+1.5);
yieldWaitForSeconds(Waiting);
this.transform.position = Vector3(XPos, YPos-0.6, ZPos+2.0);
yieldWaitForSeconds(Waiting);
this.transform.position = Vector3(XPos, YPos-1.6, ZPos+2.0);
yieldWaitForSeconds(Waiting);
this.transform.position = Vector3(XPos, YPos-2.6, ZPos+2.0);
yieldWaitForSeconds(Waiting);
this.transform.position = Vector3(XPos, YPos-4.0, ZPos+2.0);
yieldWaitForSeconds(0.25);
transform.GetComponent.<Collider>().isTrigger = true;
Destroy(gameObject);
}
}

descriptionRe: howto destroy boxes only with force not just touch

more_horiz
Use magnitude for destroy object

Code:

void OnCollisionEnter(Collision collision) {
    // apply collision damage
    if (collision.relativeVelocity.magnitude > 0.5) {
       Destroy(gameObject);
    }

Very Happy

descriptionRe: howto destroy boxes only with force not just touch

more_horiz
http://renntekstudios.co.uk
Permissions in this forum:
You cannot reply to topics in this forum