Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: DocSnickers 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?
(http://i26.photobucket.com/albums/c102/apophis3d/mousepick_zps82d42fdc.jpg)
-
Here is what my variables look like.
(http://i26.photobucket.com/albums/c102/apophis3d/mpick1_zps94b67836.jpg)
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....
-
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 (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.
-
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.
-
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.
-
That works too, if you have many tags.
-
Used in conjunction with layers would be best to reduce the number of tags and speed things up.