vp_PowerUp Change

BrandSpankingNewBrandSpankingNew Posts: 2,362Member, MPTester
May I humbly suggest that a change be made to vp_PowerUp so that it doesn't befuddle the brand spanking new guys amongst us. I thought I was losing my mind ... no snickering!

I had a variety of colliders already in existence upon a rigidbody equipped game object and I decided to re-purpose that game object as a powerup thingy.

I couldn't understand why my nasty object kept falling over.

It turned out, after adjusting the position of my other colliders in order to insure that the sphere collider was nowhere near being able to roll the object around like a ball, that I was missing the fact that the powerup script didn't care what type of collider it set as a trigger, but rather it chose the "oldest" collider, or maybe the "first" collider is a better way to say it, to set to be a trigger!

Boy, was I easily tricked by that. But, that's always the case! haha!!

Anyhow, here is my suggested fix that you might wish to place into the Start() of vp_PowerUp at the location indicated by the comment.

// set the main collider of this gameobject to be a trigger

//GetComponent<Collider>().isTrigger = true;

// BSN solving for multiple colliders that may have
// existed upon a rigidbody equiped object before
// it started a new life as a powerup of some sort.

foreach (Collider c in GetComponents<Collider> ())
if(c.GetType() == typeof(SphereCollider)) c.isTrigger = true;
else c.isTrigger = false;

Beautiful objects are wrought by study through effort, but ugly things are reaped automatically without toil.
Sign In or Register to comment.