Forum rules - please read before posting.

Is there a way to only trigger a Trigger when entering from 1 side?

I have a 3D scene with a ball that's moving with a rigidbody and a goal. I want to trigger an actionlist when a point is scored. But only when the ball is moving into the goal from the right direction. Both directions are possible, but only 1 should trigger the actionlist.

What's the easiest way to achieve this? Is there a way to check the ball's direction?

Comments

  • Yes and no. With coding there are ways to tell (using contact points and angles), which aren't always quite accurate. In this case the best practice would be to simply have multiple colliders. In your case you could have one for the Right End(front) and a big one for the Wrong End(back). Then you can record if the object entered through the righ side or not. Basically, if the object entered through the incorrect collider, you set a variable to true (EnteredWrongSide), when exiting the Wrong End or Entering the Right End you can then set it to false. This way, if EnteredWrongSide is true when they enter the Right End collider, then you just don't give the player score (by simply using a variable check). 

    You could also use three colliders, a WrongEnd (back), a Goal zone(middle), and a SafeZone(front), so if the ball entered the WrongEnd you only set EnteredWrongSide false once the ball reaches out into the SafeZone. This could be a bit more accurate, maybe.
  • Thanks Alverik. It works great!
  • Interestingly, I had the same requirement and thought multiple triggers might help but couldn't figure out the logic properly (I was trying with turning the trigger on and off based on the direction it was approached from but that would only leave you with a trigger turned off, then on when approaching from the wrong side, so same difference). @Alverik, your suggestion using Booleans and three triggers makes a lot of sense and it worked pretty well for me. Thanks for that.
  • It always impresses me how you guys invent new logic processing with variables and Actions!

    Personally, I'd probably approach it through scripting - a custom trigger that reads the object's position when entering.  A dot product between the Trigger's up direction, and the relative position between the two, should be able to determine which side of the Trigger it's on.
  • The opportunities for visual programming in AC do help, especially for folks like me who spend ages stating at text and trying to figure out how to 'wire' the logic. It's also great that there are potentially lots of ways of getting one thing done!
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.