0
\$\begingroup\$

For a 2d game, I are currently making an AI and I want it to jump when it touches a invisible cube, which isn't solid, how do I do this?

\$\endgroup\$
1
\$\begingroup\$
  • Invisible: Don't add any components that render to the screen, i.e. mesh renderer, sprite renderer, line renderer, etc.
  • Collidable: Add a physics collider to the object and set the bounds how you like.
  • Non-solid: Make the collider a trigger. Triggers will trigger a collision event, but won't have a collision response, essentially making them non-solid objects.

Add your trigger code to the OnTriggerEnter method in your script. This method is called when the trigger is first touched by another game object's collider.

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.