Author Topic: [Engine Change] Collision Layering  (Read 4874 times)

Torque's collision system is immutable by script. There is nothing an add-on maker can do to change who collides with what. That's why I'm suggesting one small addition.

Player::getCollisionLayer() - Get the object's collision layer.
Player::setCollisionLayer(int) - Set the object's collision layer.

By default, all players will have a collision layer of -1. This makes everyone bump into each other.  If this layer is changed, however, they will cease to bump into any player with the same collision layer. This property of the player should be networked for client prediction reasons.

Object #1's Layer / Object #2's Layer / Colliding?
00No
01Yes
-1-1Yes
-10Yes
-11Yes
3232No
-132Yes

This will allow TDM teams to not collide.
Zombies will not collide with zombies.

Scripts could even be setup to disable collision altogether as many people find this annoying.

Just a thought.
« Last Edit: March 04, 2011, 01:54:28 PM by Iban »



Blockland does something like this that I can't replicate with scripts - when you're in a vehicle you can't shoot it or anyone else inside, but I don't know how to disable that for e.g. raycasting weapons. (the "exclude one object" wouldn't work for other players in the car)

This'd be very helpful.

Zombies will not collide with zombies.
Wouldn't this lead to them all standing on one side of you in the same spot? Existing ones have them crowd around you, which seems better.

How about allowing it to use a bit-mask? "Your team can walk through each other and spawn doors, unless you're holding a flag"

door.setCollisionLayer($layer::team1bricks)
player.setCollisionLayer($layer::team1bricks | $layer::team1players)
holder.setCollisionLayer($layer::team1players)
« Last Edit: March 04, 2011, 02:10:37 PM by Space Guy »

How about allowing it to use a bit-mask? "Your  team can walk through each other and Sentry Guns, except for the player who made it"
So i heard you like the way TF2 works? :P

How about allowing it to use a bit-mask?
I don't know enough about bitmasks to actually write up a demonstration of this. If you could explain it in layman's terms I'd appreciate it, but this dose sound better.

I doubt Badspot even reads posts in Suggestions. But this is a good idea.

Hm...  Perhaps a playertype exclusive to a gamemode or minigame, I.e.  Rot's Zombies, TDM etc.  Be in it's own tab for information under Player Properties.

I really like this idea, but layer is the wrong word for it.  Perhaps Collision Channel or Collision ID.

Edits in Bold.
« Last Edit: March 04, 2011, 09:35:37 PM by SWAT One »

Hm...  Perhaps a playertype exclusive to a gamemode or minigame, I.e.  Rot's Zombies, TDM etc.  Be in it's own tab for information under Player Properties.

I really like this idea, but layer is the wrong word for it.  Perhaps Collision Channel or Collision ID.

Edits in Bold.
With this engine change your idea could be done, along with several other ways of doing it.
We just need the functions.

I don't know enough about bitmasks to actually write up a demonstration of this. If you could explain it in layman's terms I'd appreciate it, but this dose sound better.
They both sound nice.
I'll explain it in the way I learned bit-masks.

Let's say 1 = knife, 2 = colt, 4 = shotgun, 8 = double barrel, etc.

The starting inventory is just one integer.

1 would be knife
2 would be colt
3 would be knife and colt
4 would be shotgun
5 would be shotgun and knife
etc.

Except instead of starting weapons, this would be what the players don't collide with.

$layer::team1bricks would be 1
$layer::team1players would be 2

That boggles my mind. I'm trying to find a way in which there can be a confusion as to what the inventory will be but it doesn't break. By numerating each object with twice as much as the last, that creates gaps in which everything can fill it without overflowing into the next container. That's amazing.

I am fully in favor of what Space Guy wrote. Do eet, Badspot, do eet.

That boggles my mind. I'm trying to find a way in which there can be a confusion as to what the inventory will be but it doesn't break. By numerating each object with twice as much as the last, that creates gaps in which everything can fill it without overflowing into the next container. That's amazing.

I am fully in favor of what Space Guy wrote. Do eet, Badspot, do eet.

You know he doesn't give a flying forget... which is such a shame.

You know he doesn't give a flying forget... which is such a shame.
You never know.

Something like this, if made standard, would solve problems with IDs interfering with each other:

function getNextCollisionLayer()
{
   if($lastLayer $= "")
      $lastLayer = 0.5;
   
   $lastLayer *= 2;
   return $lastLayer;
}


If everyone used this for their mods, something like this could go in each add-on:
$ZAPT::HumansCollisionLayer = getNextCollisionLayer(); //1, unless another mod runs first
$ZAPT::ZombiesCollisionLayer = getNextCollisionLayer(); //2
...
$TeamDeathmatch::TeamCollisionLayer1 = getNextCollisionLayer(); //4
$TeamDeathmatch::TeamCollisionLayer2 = getNextCollisionLayer(); //8