playMaker

Author Topic: Detect when GameObject out of view [Solved]  (Read 6011 times)

izzycoding

  • Playmaker Newbie
  • *
  • Posts: 29
Detect when GameObject out of view [Solved]
« 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,
« Last Edit: May 20, 2013, 03:13:43 AM by izzycoding »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Detect when GameObject out of view
« Reply #1 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!

izzycoding

  • Playmaker Newbie
  • *
  • Posts: 29
Re: Detect when GameObject out of view
« Reply #2 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,

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Detect when GameObject out of view
« Reply #3 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.

izzycoding

  • Playmaker Newbie
  • *
  • Posts: 29
Re: Detect when GameObject out of view [Solved]
« Reply #4 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,

izzycoding

  • Playmaker Newbie
  • *
  • Posts: 29
Re: Detect when GameObject out of view [Solved]
« Reply #5 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,

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Detect when GameObject out of view [Solved]
« Reply #6 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

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Detect when GameObject out of view [Solved]
« Reply #7 on: May 22, 2013, 07:10:39 AM »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D