Forum rules - please read before posting.

PointTrigger2D for any object with Component

Hi!

I found PointTrigger2D on the the Fandom Wiki, which sounds exactly what I was looking for, but I can't seem to find a way for the trigger to find "any object with component". Basically, as far as I can tell, the PointTrigger2D can be affected only by one, specific object. Is there any way to make it have an effect on any object with a component, similarly to a usual AC Trigger?

Simply looking for a way to have a trigger run a Cutscene after any of the possible characters walks into the trigger, not just one.

Comments

  • Is there any way to make it have an effect on any object with a component, similarly to a usual AC Trigger?

    No, but you could add a separate instance of the component for each character. Otherwise, using the official Trigger2D would be the way to go.

  • edited February 2019

    I have a lot of characters in my game, and ideally I would need the trigger to work with all of them.

    Adding a separate instance of the component for each character might be easily overlooked and lead to bugs.

    I guess using the official Trigger2D would be a better option, but I'm wondering how much of a performance effect it would have, if each character had a Rigidbody2D on them? I'm guessing it could have quite an impact, as otherwise all NPC characters would have Rigidbody attached by default?

  • "A lot" can mean many things, but its true that Rigidbody2D components can have an impact on performance - particlarly on mobile.

    The techniques between the two Trigger scripts are different - but you can still adapt the PointTrigger2D to check through an array of objects.

    Try this:
    http://pasteall.org/1512428/csharp

  • Thank you! Instead of making multiple instances of the same script, I can just add characters to the array on this one instance. This should do the trick.

    Thank you once again!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.