Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: izzycoding on May 19, 2013, 09:37:15 AM

Title: Detect when GameObject out of view [Solved]
Post by: izzycoding on May 19, 2013, 09:37:15 AM
Hi,

I have a scene where I need to be able to detect when an object is out of view.
For example, my character throws a bouncy ball, when the ball goes out of view I want the FSM to detect this and destroy its self.
Is there anything that can do this for me?
I was previously using a script in the OnBecameInvisible function to detect this.

Any ideas would be great.

Regards,
Title: Re: Detect when GameObject out of view
Post by: Alex Chouls on May 19, 2013, 02:07:38 PM
Playmaker has a built in system event: BECAME INVISIBLE.

This is fired by the OnBecameInvisible event. So it's equivalent to what you were doing before.

Use this event in a global transition to activate a state and run actions when the GameObject becomes invisible.

Note: Unity uses ALL cameras to determine visibility, including the Scene View camera! Take this into account when testing!
Title: Re: Detect when GameObject out of view
Post by: izzycoding on May 19, 2013, 03:13:17 PM
Hi,

That is great, where do i find that? As I cant see it anywhere.
Currently I only have a single camera in my scene so that should be fine.

Regards,
Title: Re: Detect when GameObject out of view
Post by: Alex Chouls on May 19, 2013, 03:31:27 PM
When you right click on a state to add a transition you can drill down to System Events.

See attached image.
Title: Re: Detect when GameObject out of view [Solved]
Post by: izzycoding on May 20, 2013, 03:14:41 AM
Hi,

Great thanks, I knew it would be something simple.

:-) I was looking for an Action for this....lol

Regards,
Title: Re: Detect when GameObject out of view [Solved]
Post by: izzycoding on May 22, 2013, 03:34:00 AM
Hi,

I have replaced my playmaker stuff to use the system event.
I have only 1 camera in my scene but this event never triggers the BecameInvisible State.
Am I doing something wrong here?

Regards,
Title: Re: Detect when GameObject out of view [Solved]
Post by: jeanfabre on May 22, 2013, 03:44:12 AM
Hi,

 Read the comments above, basically, I think you are confused with a unity bug, where the object also must be out of the "scene" view in editor,

I tested and works fine, so make sure that the object is actually not still visible on the scene, else it will not fire.

bye,

 Jean
Title: Re: Detect when GameObject out of view [Solved]
Post by: Lane on May 22, 2013, 07:10:39 AM
There's a little history on that here:

http://hutonggames.com/playmakerforum/index.php?topic=3825.0