playMaker

Author Topic: Inside Collider Info  (Read 4555 times)

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Inside Collider Info
« on: November 20, 2015, 12:04:23 PM »
This might be useful for someone.

What does it do? It checks if the gameobject is inside (or partially inside) a collider. Useful for defining areas with colliders.

Example of usage:

Put a collider on an empty gameobject. Set the size of your collider.

1. Am I, a gameobject (renderer or sprite if 2d) inside this collider? Yes, send this event, No send this event.

2. Use with Array tool actions to check if a list of gameobjects are inside a list of colliders. Set a collider(s) as an FsmObject and loop.

on ecosystem or https://snipt.net/dudebxl/

3d version is tested. 2d Version not tested. Any problems, please post here.

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Inside Collider Info
« Reply #1 on: November 20, 2015, 11:14:03 PM »
Very useful! Thank you!
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

10high

  • Playmaker Newbie
  • *
  • Posts: 33
    • Cult Manager - Google Play
Re: Inside Collider Info
« Reply #2 on: October 28, 2021, 12:37:31 PM »
I tried using the 2D version of this and it returns the error that it can't access the "Sprite" component on my GO because it doesn't have one.

So, I changed the script to work with "Renderer" instead. It seems to work as intended but perhaps someone else wants to see if anything else in the script needs updating. I literally changed just one line and me no code good can.

By the way, this action uses bounds, so it doesn't actually check whether the GO is inside the collider but whether it is inside the bounds. As I understand it, the bounds are rectangular, so if your collider isn't simply a rectangular shape the action can return an incorrect result.
« Last Edit: October 28, 2021, 12:50:27 PM by 10high »
Cult Manager