playMaker

Author Topic: Deactivate/Activate when Camera out/on Objects?  (Read 3919 times)

Mayhem

  • Full Member
  • ***
  • Posts: 171
Deactivate/Activate when Camera out/on Objects?
« on: May 08, 2013, 04:15:45 AM »
Hey there, I have a question regarding the Memory Usage :)

I am working with 2D Toolkit now and wanted to know something.

So in my very first Level there are now over 100 Sprites (which are of coursed batched. I've got 4 Texture-Atlases, a nGUI-UserInterface and some other stuff. Around 8-10 DrawCalls). I'm structuring them like this: an Empty GameObject is called for example "PLATTFORM_01" and it has the SpriteObjects as children. In the Scene-View one can see the whole Level. The next Level will be much bigger and longer and I guess I can't handle it that way, can I?
How can I deactivate/activate the Plattform-Objects (which will deactivate the Sprite-"Children") when the Objects    are not/are    shown by the camera in order to save memory? I'm asking because I'm targeting mobile devices :)

The thing is, when I attach a FSM to that GameObject AND deactivate it right in the Inspector, the FSM will be never triggered.

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Deactivate/Activate when Camera out/on Objects?
« Reply #1 on: May 08, 2013, 04:21:46 AM »
There is an action called "Game Object is Visible - not I had a play with it and I'm not sure what it does ... it could be a bug but it doesn't work when the gameobject is not visible by the camera.

So a second option is to use the distance between the camera and the platform ... if the game is 2d. If its 3d you could look at the Playmaker AI youtube video to look at the cone angle and how you could use that to turn things off.

Hope that helps :)

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: Deactivate/Activate when Camera out/on Objects?
« Reply #2 on: May 08, 2013, 04:30:44 AM »
Thanks for the reply! :)
Yeah, I already tried "Game Object is Visible". Didn't work out nice for me.

Hm, but how can I measure the distance with an Object which is deactivated?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Deactivate/Activate when Camera out/on Objects?
« Reply #3 on: May 08, 2013, 06:41:44 AM »
Thanks for the reply! :)
Yeah, I already tried "Game Object is Visible". Didn't work out nice for me.

Hm, but how can I measure the distance with an Object which is deactivated?

May want to glance through this just to make sure.
http://hutonggames.com/playmakerforum/index.php?topic=3825.msg17742#msg17742
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: Deactivate/Activate when Camera out/on Objects?
« Reply #4 on: May 08, 2013, 06:50:14 AM »
Thanks for the reply, Lane, but that doesn't solve the "problem" with an already deactivated Gameobject, does it?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Deactivate/Activate when Camera out/on Objects?
« Reply #5 on: May 08, 2013, 06:51:36 AM »
Probably not, but it doesn't exactly work as expected in regards to the game view either so I figured it may be work a quick try.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: Deactivate/Activate when Camera out/on Objects?
« Reply #6 on: May 08, 2013, 07:01:36 AM »
Hm, I was told that the Amount of Sprites in the Scene doesn't matter at all, it's about the TextureAtlasses and the size of them.

But just for the sake of interest, maybe it will come in handy:

If a GameObject with a FSM attached is deactivated at start and is activated by the camera-"movement", there is only one solution, isn't it:

- there has to be another GameObject (an empty one, let's call it: "DistanceChecker") which has a FSM attached and is positioned at the same spot the deactivated one is;
- from there that DistanceChecker will...yeah, check the Distance  :D  and if the camera is near - the DistanceChecker activates the deactivated GameObject.