playMaker

Author Topic: Raycast: How to check collision through/or ignore specific gameobject [SOLVED]  (Read 2664 times)

Sly

  • Full Member
  • ***
  • Posts: 124
Hello folks!

Actually I'm still on my 2d top view game.
I'm using raycasting in my AI to check if the player is nearby.
The problem is my AI can't detect my player is there is a barrel in between. We will agree a barrel (or gameobject of this type) should not be very tall and should not obstruct the AI view.

My question is the following: is there a way to raycast through specific gameobject or to ignore them?

Thanks in advance and thanks again for all the helps you all already provide :)
« Last Edit: June 27, 2014, 01:58:03 PM by Sly »

Khoa1994

  • Playmaker Newbie
  • *
  • Posts: 33
Assign layer to your objects. When raycasting, you can specify the layer that the ray can detect whether it hits an object.

Sly

  • Full Member
  • ***
  • Posts: 124
Hello.

Yes you right! That's perfect! It's a good way to solve my problem.
Thank you very much Khoa1994!