playMaker

Author Topic: Raycasting though walls?  (Read 3822 times)

DocSnickers

  • Playmaker Newbie
  • *
  • Posts: 3
Raycasting though walls?
« on: February 27, 2013, 12:08:22 AM »
So I seem to have a problem with mouse pick and raycasting through walls. I am using a mouse pick event which is tagged to a layer using a dummy object. When the player clicks on the object the camera turns and moves towards it. That all works great but if there is a wall in your way and you know there is a dummy object behind that wall you can click the wall and it will move right though to that dummy object.

I am using a bool to check for the dummy object. Which in theory when I click a wall it should not see the dummy object because it's blocked?

DocSnickers

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Raycasting though walls?
« Reply #1 on: February 27, 2013, 07:27:14 PM »
Here is what my variables look like.



I am using layers to control raycasting. I have my clickable movement blocks set up to be the layer to be clickable though a mouse pick. Then I have everything else on the ignore raycasting layer however I can click on something though the wall and move to it....

MediaGiant

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Raycasting though walls?
« Reply #2 on: March 27, 2013, 10:47:17 AM »
Hi DocSnickers,
I'm having the same issue with terrain picking and I believe it is happening because Mouse Pick is just checking to see if the ray and object collide regardless of whether other objects are also on that ray. I wrote a ray/polygon intersection test back in 2003 (http://www.alsprogrammingresource.com/selection_tutorial.html) so naturally I guessed that Mouse Pick would only register for the closest object but I suspect it isn't. If anybody else has a solution I'd be happy to know but I fear I'm going to have to write my own Mouse Pick Closest Object action.   

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Raycasting though walls?
« Reply #3 on: March 27, 2013, 11:07:06 AM »
Set your walls on a layer, then add another Layer Mask (for walls) to your Mouse Pick.

Then store the layer that has been picked and run to a check state, if it is a Wall then loop back to the start, if it is the object you want then continue.

It's just an interrupt to check if you hit any walls. That's all.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

MediaGiant

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Raycasting though walls?
« Reply #4 on: March 28, 2013, 12:37:16 PM »
After a little bit of digging I am leaning towards using tags. If you use Mouse Pick without a layer mask and then use multiple Game Object Compare Tag actions with only their True Event transitions set then you can create a switch block of transitions. Finish with a Send Event as a default action.
« Last Edit: March 28, 2013, 01:11:10 PM by MediaGiant »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Raycasting though walls?
« Reply #5 on: March 28, 2013, 12:54:17 PM »
That works too, if you have many tags.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

MediaGiant

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Raycasting though walls?
« Reply #6 on: March 28, 2013, 01:18:55 PM »
Used in conjunction with layers would be best to reduce the number of tags and speed things up.