Detect collision with specific object collision( Col-n )
by Alejandro Lopez · in General Discussion · 06/15/2008 (2:30 pm) · 3 replies
I have a player who has various collision boxes , one for the body and 2 others for the arms .
Are any way to know when the col-2 collide with a object ?
Are any way to know when the col-2 collide with a object ?
#2
Cause in that, I know you use the 'onCollision' function (check the included html documentation), and simply check to see if the object it hits has a specific class (or doesn't have one for that matter).
As an example, here's a peice of some of my platform game code (when the player hits the enemy) :
function playercontroller::onCollision(%this, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts) {
if(%dstObj.class $= "enemyA") {
%this.owner.setLinearVelocityY(-100);
if ((%this.owner.getPositionY() + 4) < %dstObj.getPositionY()) {
%dstObj.onHit();
%this.stunned = false;
}
else {
%this.stunned = true;
%this.health = %this.health - 1;
%dstObj.onGetHit();
sceneWindow2D.startCameraShake(90.0, 0.7);
}
}
}
10/14/2008 (12:33 pm)
Are you talking about TGB?Cause in that, I know you use the 'onCollision' function (check the included html documentation), and simply check to see if the object it hits has a specific class (or doesn't have one for that matter).
As an example, here's a peice of some of my platform game code (when the player hits the enemy) :
function playercontroller::onCollision(%this, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts) {
if(%dstObj.class $= "enemyA") {
%this.owner.setLinearVelocityY(-100);
if ((%this.owner.getPositionY() + 4) < %dstObj.getPositionY()) {
%dstObj.onHit();
%this.stunned = false;
}
else {
%this.stunned = true;
%this.health = %this.health - 1;
%dstObj.onGetHit();
sceneWindow2D.startCameraShake(90.0, 0.7);
}
}
}
#3
The Hitbox Tutorial
Hand to Hand Combat, Locational Damage and Collision and More
The code is old but should give you an indication of how to make it work.
10/14/2008 (1:33 pm)
These might help:The Hitbox Tutorial
Hand to Hand Combat, Locational Damage and Collision and More
The code is old but should give you an indication of how to make it work.
Torque Owner Lee Latham
Default Studio Name
It'd be great if you posted a resource for it :-)