PlayMaker Help & Tips > Android Help

Touch Object on different cam

(1/2) > >>

zombie_farm:
I have set up an ortho cam for my GUI and have normal objects(not GUI) in front of it that I need to touch and preform actions on. I can't get the touch object event to recognize my second cam.

Thanks!

kiriri:
should be based on the main camera ("set main camera"), I think.

Cheers,
kiriri

zombie_farm:
Isn't possible to fire a ray from both cams?.. I still have interactive elements in front of my main can. Its a story book for kids.

kiriri:
well, sure it is but you have to do it manually.
First check for touches with the touch event action. Do this FSM on one object only in the entire scene. On touch,
 use set active camera (camera1), then use screen cast, then use set active camera (camera2) and then use screen cast again.
In both cases store the hit point. Then calculate both distances (get position (camera1) - hit point 1), same for camera 2.
Then compare the distances and find out which object is closer to the respective camera. The closer one should then be the one touched.
Then send a global event to the FSM on that object (like, "activateButton" or something similarily unique. If the object does not contain an FSM or if the global event is not inside, it'll complain but it won't cause any issues whatsoever in the compiled build)

If you use your second camera to layer a gui (or the like) on top of your first camera, you can also compare if the screencast of your gui camera returned as a hit object null ("Game Object Is Null"), and if it is, you can try the next screen cast on your second camera, and if it isn't you'll continue with that point/object.
That way it'll get whatever is on top of that par of the screen (whatever is rendered there, unless it's transparrent of course).

That's all I can think of off the spot. Hope it helps.

Best,
Sven

zombie_farm:
Great thanks Sven!

Navigation

[0] Message Index

[#] Next page

Go to full version