Hello Guest

Author Topic: attach points w/ on trigger  (Read 5718 times)

micky

  • Newbie
  • *
  • Posts: 23
    • View Profile
attach points w/ on trigger
« 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: attach points w/ on trigger
« Reply #1 on: October 16, 2013, 10:55:21 am »
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 :)

micky

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: attach points w/ on trigger
« Reply #2 on: October 16, 2013, 04:45:41 pm »
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 :/

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: attach points w/ on trigger
« Reply #3 on: October 17, 2013, 01:22:59 am »
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.

micky

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: attach points w/ on trigger
« Reply #4 on: October 18, 2013, 04:43:20 am »
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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: attach points w/ on trigger
« Reply #5 on: October 18, 2013, 11:59:00 am »
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.