2D Toolkit Forum
2D Toolkit => Support => Topic started by: micky on October 15, 2013, 11:07:58 pm
-
So I noticed with a sprite that has a trigger collision box that has attachment point weapons with trigger collision boxes, if an enemy hits either the weapon or the players box, there doesnt seem to be a way to tell them apart? I can tell when the weapon hit something because that has its own script, but when something hits either player box during an attack frame, I can't tell which one its hitting if that makes sense.
Website looks amazing now btw, gj.
-
You can attach whatever you like on the attach point - it could even be a box collider with its own script / tag / layer on there to help you identify whats hitting what.
Glad you like the website, makes it look less 90s :)
-
Ya I did that much, so like, when walking into each other I get this currently
-----------------
player touched enemy -> no problems yet
enemy touched player -> no problems yet
on attached weapon hit (with its own collider) I get this though
----------
player touched enemy -> cant tell if this originated from the weapon because all I get is the enemy collider in ontriggerenter, which is the enemy, I cant tell if it's the weapon collider or the players sprite collider
enemy touched player -> same
weapon touched enemy -> this part works fine because a separate script is attached to the weapon
I think it's because the weapon attach points are parented it's considered all the same collider? confused as to how to get this working :/
-
So it returns the enemy collider, regardless of what subcollider it actualyl hits? Do you have a (kinematic) rigidbody on this collider? If you dont, I recommend trying with it in there. It won't merge colliders across rigid body boundaries.
-
The sprite has a 2D Toolkit generated box collider set to trigger with a kinematic rigid body attached, and then the weapon attach point is the same thing,
I read that somewhere and tried it but I still get the same effect, the weapon hits it and I get an event from the weapon and the sprite.
I'm reading some other things on the unity forums says I need to use OnCollision for contact points or something because it's a compound, but I'm not using the physics engine (mostly rays) so both have to be triggers.
-
I've run out of things to suggest now. I'll be happy to look if you create a simple repro case for this. support at unikronsoftware.com if you'd like to do that.