CollisionManager Callbacks

Chipmunk2D Bindings for the Unity3D engine
Post Reply
runonthespot
Posts: 8
Joined: Fri Aug 16, 2013 10:42 am
Contact:

CollisionManager Callbacks

Post by runonthespot »

Hi, just didn't want to hijack the other thread.

Basically some questions:
Firstly, in a test scene, I tried a callback like so:

Code: Select all

	
bool ChipmunkBegin_ball_box (ChipmunkArbiter arb)
{
	Debug.Log("Collided on "+transform.name);	
	return true;
}
which I then placed on on two objects, one a sphere with circle shape + body, and one a cube with box shape + body.

I can't seem to get both to fire at the same time. In my case it only ran the one on the sphere, until I removed it, and then it started running on the cube. Is this how it is meant to work?

Thanks,
Mike
runonthespot
Posts: 8
Joined: Fri Aug 16, 2013 10:42 am
Contact:

Re: CollisionManager Callbacks

Post by runonthespot »

...also in a larger existing class, where I was trying to replace OnTriggerEnter with a ChipmunkBegin_box_orb routine, I could not get it to fire at all. I tried normal collider, sensor, and with it set to IsKinematic, and without, but nothing could make the event fire. With it set to IsSensor = false, the objects are actually physically colliding, just no event to speak of. I've eliminated all the usual suspects like ensuring all layers collide, setting appropriate types, etc etc.

I'm pretty sure it's registering *some* sort of handler, because I tried adding a Debug.Log event of the same name to a different script on the same object, with the objects switched around (e.g. orb_box), and it at least complained that the order had to be the same if there was more than one handler.
runonthespot
Posts: 8
Joined: Fri Aug 16, 2013 10:42 am
Contact:

Re: CollisionManager Callbacks

Post by runonthespot »

Still having strangeness with 1.0.3 unfortunately. I'm worried that I'm misunderstanding how things should work with collision callbacks:

Namely, can I have two classes, both subclassing ChipmunkCollisionManager, both implementing the same callback, e.g.
ChipmunkBegin_orb_box()...

so that I can implement behaviour on the box, and behaviour on the orb that differs?
runonthespot
Posts: 8
Joined: Fri Aug 16, 2013 10:42 am
Contact:

Re: CollisionManager Callbacks

Post by runonthespot »

Just an update here, apparently this is working as intended. In Unity you get to implement the callback only once, e.g. ChipmunkBegin_orb_water has a single implementation. (Thanks to the chipmunk authors for getting back to me so promptly)

I'm working on implementing an event class that dispatches these events to listeners, which seems the most sensible way to distribute the events, where the implementation may differ between bodies.
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests