Game Development Community

Collision troubles

by Drew -Gaiiden- Sikora · in Torque Game Builder · 03/10/2006 (7:50 pm) · 1 replies

This is driving me nuts. I have a missile that gets launched from one map tile to another. The game can have sprite walls around a map tile so I want the missile to collide with the edge of the tile so I can check for a wall. If there is one the missile explodes, if there isn't one the missile continues on and collides with the planet. My problem is getting the missile to continue on to the planet. It just won't budge once it hits the edge of the map tile!!

Here's the missile creation code
$spaceMissile = new t2dStaticSprite() { scenegraph = gcSceneGraph; };
$spaceMissile.setPosition(%launchPosition);
$spaceMissile.setSize("19 10");
$spaceMissile.setRotation(t2dAngleBetween(%launchPosition, GameData.targetSystem) - 90);
$spaceMissile.setImageMap(spaceMissileImageMap);
$spaceMissile.setGroup(1);
$spaceMissile.setLayer(1);
$spaceMissile.setCollisionActive(true, false);
$spaceMissile.setCollisionPolyPrimitive(4);
$spaceMissile.setCollisionMasks(BIT(1), BIT(1));
$spaceMissile.setCollisionCallback(true);
$spaceMissile.setCollisionResponse(sticky);
and here's the code for enabling collision with the map tile
GameMap.map.getTileLayer($TILE_SYSTEMS_LAYER).setGroup(1);
GameMap.map.getTileLayer($TILE_SYSTEMS_LAYER).setLayer(1);
GameMap.map.getTileLayer($TILE_SYSTEMS_LAYER).setCollisionActive(false, true);
GameMap.map.getTileLayer($TILE_SYSTEMS_LAYER).setCollisionMasks(BIT(1), BIT(1));
GameMap.map.getTileLayer($TILE_SYSTEMS_LAYER).setCollisionSuppress(false);
GameMap.map.getTileLayer($TILE_SYSTEMS_LAYER).setTileCollisionActive(GameMap.getTilePosition(%worldPosition), true);
GameMap.map.getTileLayer($TILE_SYSTEMS_LAYER).setTileCollisionPolyPrimitive(GameMap.getTilePosition(%worldPosition), 4);
I launch the missile using the moveTo command
$spaceMissile.moveTo(GameData.targetSystem, 100, true, true);
when the collision callback function is called I check the system for any walls in the way of the missile. If there isn't one then I try to restart the missile towards the target
// disable collisions
GameMap.map.getTileLayer($TILE_SYSTEMS_LAYER).setCollisionSuppress(true);
$spaceMissile.setCollisionSuppress(true);

// carry out appropriate action
if (!%isWallErected)
	$spaceMissile.moveTo(GameData.targetSystem, 100, true, true);
This is the exact same moveTo command I originally used and the missile refuses to budge. The callback function is only called once (I echoed "test" to the console at the start of the function and it only appeared once) and I've done all I can to disable collisions. Weirder yet if I move the missile back and then call moveTo it still doesn't work. I've even tried calling the setPositionTargetOff command beforehand as well to no avail.

Anyone have any idea what's going on here? I've been stuck on this for like two hours now it's killing me. Thx

#1
03/13/2006 (9:35 am)
Well, I realized later while I was trying to sleep that - duh - the walls are sprites so why not just have the missiles collide with the walls?? Oh gee that only took like 30 mins to get working right. Gah sometimes my blindness amazes me :-p

Still, if anyone has any idea what the heck went screwy with this tile approach I'd like to know.