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?
- 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.