Collision with one object killed and other bounced
by Steven Hine · in Torque Game Builder · 05/29/2006 (10:09 am) · 2 replies
I'm trying to make one object bounce of another, but have one object killed on contact. Like in a breakout style game. Anyone have an idea how I can do this?
About the author
Torque Owner Anthony Fullmer
function Block::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts ) { if(%dstObj.class $= "Ball") { // If a ball hit us, or we hit a ball... (we are dead) // Then delay destroy ourselves so the ball bounces! %srcObj.schedule(20, "destroyBlock"); } } function Block::destroyBlock(%this) { %this.safeDelete(); }Also, you will have to change your collision response for your ball. To do this, go into the edit tab of your ball object and find the collision rollout. Inside the collision rollout, change your response mode to "BOUNCE". Hope this helps out!