Moving actors off-scene

IgnisIgnis Member Posts: 72
edited November -1 in Working with GS (Mac)
I want to use the tactic which was recently discussed (if I recall) to temporarily move actors off the screen, so they don't have any effect on the game... but I want to keep them around, because they appear and re-appear in a pattern. I definitely don't want to Destroy > Spawn > Destroy > Spawn etc.

To do this, I have assigned the actor prototype an attribute "InitX" (integer). I hard-code that value in each individual actor instance to match its starting position in the scene... there is probably a more efficient method, but I don't mind doing this because there won't be more than 10 of these actors in any given scene, and they never deviate from their initial position unless I force them off-scene.

So this is probably a simple question with an obvious answer:
When I force the actor off-scene, can I just use some excessively high X-position integer like 5000? 10000? My test scene is 720 pixels wide, but this might increase. I can't imagine going above even 3000, but 10000 would ensure its disappearance, unless for some reason GS has a problem with this?

Comments

  • IgnisIgnis Member Posts: 72
    Now this is odd... when the vanishing actor is off-scene, other actors still seem to collide with it, even though it's not there anymore! I need to test further; maybe I missed something. Does GS use initial X and Y positions, along with width and height and collision shape and somehow keep that in memory, so the actor is still "there" but not really there? Weird... if anybody else has observed this, please let me know. I can certainly find a workaround if necessary.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You can NOT use a really high integer like 5000 or 10000... GS automatically destroys Actors when they are a certain distance from the edge of the Scene (not the camera edges, the Scene edges). So if, for example, your Scene is 5000 pixels wide, the Actor will get destroyed at 5500 pixels. If your Scene is 1024 pixels wide, your actor will get destroyed at something like1200 pixels.

    I don't know the exact distance as it's not a fixed number, but a ratio - it depends on the size of your Actor.

    So if you are hiding Actors just off the side of the Scene, that is fine, just don't put them too far away.

    That being said, they are still ACTIVE in the Scene. I'm pretty sure that the collision system still has to process them and the graphics system is still rendering them.

    This technique just saves you from spawning/destroying which can cause the game to hiccup if those actors are Rule-heavy.

    So even though the Actors are off-screen, you still have to deal with them.

    You should have a Rule that checks their position, and sets a boolean if they are off-screen or not. Something like "self.hidingOffScreen" . Only collide with that object when that is false, etc...
  • IgnisIgnis Member Posts: 72
    firemaplegames said:
    That being said, they are still ACTIVE in the Scene. I'm pretty sure that the collision system still has to process them and the graphics system is still rendering them.

    This technique just saves you from spawning/destroying which can cause the game to hiccup if those actors are Rule-heavy.

    Thanks FMG, I'll keep this in mind. These actors and their behavior aren't 100% imperative to my game idea, so I might have to delete them eventually if the performance gets sluggish; either way it's good to know how I should "hide" them, and where.
Sign In or Register to comment.