Game Development Community

About onEndCollision ? (Sloved!)

by KevinYuen · in Torque 2D Beginner · 03/15/2013 (9:49 am) · 4 replies

function init(...)
{
   ...

   %this.CollisionShapeId = %this.owner.createCircleCollisionShape( %this.owner.FireRange );
   if( %this.CollisionShapeId == -1 )
   { 
      return false;
   }
   
   %this.owner.setCollisionShapeIsSensor( %this.CollisionShapeId, true );

   ...
}

function ObjectBehaviorHotArea::onCollision( %this, %sceneObject, %collisionDetails )
{
   echo( "onCollision: " @ %this @ " # " @ %sceneObject @ " # " @ %collisionDetails );
}

function ObjectBehaviorHotArea::onEndCollision( %this, %sceneObject, %collisionDetails )
{
   echo( "onEndCollision: " @ %this @ " # " @ %sceneObject @ " # " @ %collisionDetails );
}

output:

onCollision: 1240 # 1247 # 0 1
onEndCollision: 1240 # 0 1 #

%sceneObject was missing in onEndCollision?

I need to confirm who leave my area, help me :)

#1
03/15/2013 (12:45 pm)
I believe this is a bug due to a recent change.

I have just committed a fix here. Please let me know if this fixes it for you.
#2
03/15/2013 (5:22 pm)
result:

onCollision: 1240 # 1247 # 0 1
onEndCollision: 1240 # 1247 # 0 1

thank u for your help :)

#3
03/16/2013 (4:21 am)
You are most welcome.
#4
03/21/2013 (6:52 am)
update params:

function ObjectBehavior::onCollision( %this, %thisowner, %sceneObject, %collisionDetails );

function ObjectBehavior::onEndCollision( %this, %thisowner, %sceneObject, %collisionDetails );