Game Development Community

No collision send from mounted objects?

by Michael Woerister · in Torque Game Builder · 06/09/2006 (6:12 am) · 22 replies

Hi,

I've got an object with this datablock:
datablock t2dSceneObjectDatablock(dataBlackJackRep)
{
   Class = "BlackJackRep";
   Size = "5 60";
   
   CollisionActiveReceive = false;
   CollisionActiveSend = true;
   
   CollisionPhysicsReceive = false;
   CollisionPhysicsSend = false;
   
   CollisionGroups = "15";
   CollisionLayers = "15";
   
   CollisionCallback = true;
   
   imageMap = "puzzleBlock_4ImageMap";
};

And this is the object it should collide with:
new t2dStaticSprite() {
      imageMap = "puzzleBlock_2ImageMap";
      position = "13.5548 -17.2352";
      size = "8 8";
      Layer = "15";
      GraphGroup = "15";
      CollisionActiveReceive = "1";
      CollisionPhysicsSend = "0";
      CollisionPhysicsReceive = "0";
         mountID = "3";
   };

This object is mounted to another one. But the collision callback does not get called when it collides. The other way round (2nd object sending, 1st receiving) it works perfectly.
But I need the first object to send because it should collide with tilemaps (which can only receive).

Am I doing something wrong? Is this a bug? Or does this not work on purpose?

-Michael

EDIT: Corrected the typo Tom found.
Page «Previous 1 2
#1
06/09/2006 (6:18 am)
You set CollisionActiveSend to true, then 2 lines later set it to false. The second one you probably meant to use CollisionPhysicsSend = false;.

Quote:
CollisionActiveSend =true;
   
   CollisionPhysicsReceive = false;
   CollisionActiveSend = false;
#2
06/09/2006 (6:25 am)
Yes, you are right, thanks.

But it still doesn't work :/
#3
06/09/2006 (6:40 am)
Absolutely should work; as far as I can remember the underlying engine should allow this. The exception is that physics cannot be sent/received if an object is rigidly mounted. This is the last stage of the collision routine though and you should still get a callback. Hmmm, not sure.

- Melv.
#4
06/09/2006 (6:51 am)
The object is rigidly mounted. But from skimming a bit through the code I couldn't find a reason why it doesn't get called. Maybe somewhere checkCollisionSend or something is skipped for rigidly mounted objects?
#5
06/09/2006 (7:45 am)
I don't recall every restricting it that way because I thought that it was still valid for rigidly mounted objects to send/receive collisions but not to have a physics response.

I'll check this when I get home and post here.

- Melv.
#6
06/09/2006 (7:49 am)
I stepped through it with the debugger. It seems to be a bug with the collision masks. When I set the collision masks manually through script later, it works. I will try it in RC2. Maybe this has already been resolved.
#7
06/09/2006 (7:57 am)
Hm, it seems that you have to specify collision groups and layers as a bit mask in the datablock. The ConsoleMethod takes a list of numbers (in RC1 and RC2).
I think the datablock should take a list of numbers too. Or it should be called "CollisionGroupMask". As it is now, it is misleading.
#8
06/09/2006 (11:12 am)
Yeah, that is a little confusing. I'm wondering if changing that now would break alot of functionality. I agree though, it's a little confusing particularly as the actual mask call explictly has the "mask" suffix.

I'll forward this one onto Justin to see what he thinks.

- Melv.
#9
06/09/2006 (12:05 pm)
Thanks Melv!

I was just about to post this in the suggestions forum. This better ought to be changed sooner than later, I guess.
#10
06/13/2006 (3:16 pm)
@Michael

Would it be possible for you to give a code example of how you specified the collision groups and layers in the datablock?

I am having the same problem where my mounted objects will not collide. I thought maybe it was just something I was doing wrong but I just can't get it to work no matter what.

I've tried to specify the collision groups in the datablock also but still had no luck.

Any help would be greatly appreciated.
Thanks

- Jim.
#11
06/14/2006 (12:26 am)
As it is now, you have to specify them as a bit mask like this:

CollisionGroups = BIT(1) | BIT(2) | BIT(3);
   CollisionLayers = BIT(7) | BIT(20);
instead of
CollisionGroups = "1 2 3";
   CollisionLayers = "7 20";

I hope that helps.
#12
06/14/2006 (10:12 pm)
@Michael

Thanks for posting that. I've tried it but I still can't get it to work.

Unfortunately this is a show stopper for me because my game won't work without this functionality. I will have to dynamically change the collision poly of the parent object to accommodate the position of the mounted object and hope I don't take too much of a performance hit.

Anyway, I better get scripting, thanks again.

-Jim.
#13
06/15/2006 (2:51 am)
You can post the collision settings of your objects if you want. Maybe someone here can spot an error in it.
#14
06/20/2006 (3:14 pm)
Has this issue been fixed in the 1.1 release?

I only ask because it will be a few days before I can get my hands on TGB 1.1 but knowing if this has been resolved will allow me to rethink the way I can implement my game.

-Jim.
#15
06/21/2006 (12:29 am)
No, it has not changed yet.
#16
06/25/2006 (7:37 pm)
Your problem is here:

CollisionGroups = "15";
   CollisionLayers = "15";

If what you want is the object to collide with GraphGroup 15 and Layer 15, what you need is the following:

CollisionGroups = "32768";
   CollisionLayers = "32768";

Why 32768 you ask? Remember, youre dealing with a bitmask, so instead of 15, you need 2^15, which is 32768. Thus, for collision group 0, you need "1", for collision group 1 you need "2", for collision group 2 you need "4", and so on. It sounds convoluted but it makes sense if you think about it, because you can just add the values of the groups you want and thats your mask. For example, if you wanted both group 0 and group 1 you would use "3".

Hope this helped.
#17
06/25/2006 (7:41 pm)
Also, in case anyone was wondering, "15" gives you only groups/layers 0, 1, 2, and 3 - which is why you weren't getting collision over group/layer 15.
#18
06/26/2006 (1:37 am)
Thank you. I already had solved this if you read the above posts. I recommend using BIT(15) function instead of 32768.
#19
06/26/2006 (3:30 am)
I am glad that your issue has been resolved, and yes I read this thread before I replied, as I normally do on any forum. However, this particular forum is for everyone with a license and not all questions in this thread had been answered, so I decided to write out what had yet to be explained in this thread. Yes, it may be easier for you to comprehend collision bitmasks by setting them using BIT(), but that wouldn't explain to someone searching through the forums for answers to a similar problem the unfamiliarity of the number that their Groups or Layers bitmask is stored as (specifically because TorqueScript stores every value as a string), were they to actually check them for themselves. Your wording was a little misleading when you wrote "you have to specify them as a bit mask like this...", so I clarified for anyone who might stumble onto this thread in the future. I generally like to know what's going on behind the scenes and I happened to run into this very issue on my own about a week ago when I first started tinkering with collision. That's why I felt it might be appropriate to contribute to this thread.
#20
06/26/2006 (3:42 am)
@Thomas
Hey, no offense intended. I was just wondering because in your first post you seemed to talk directly to me (at least I read it that way).
Page «Previous 1 2