Rules not working for off screen actors...

What I want to happen is the actors to move onto the screen, then move left and right within set parameters, essentially going left and right. My set up is pretty simple:

In the actor I have created a start_x attribute, which changes the self.x on start/reset so that I can reload the actor positions without changing scene. Since I'm working to iPad resolution the start_x is either 100 or 800 depending on if the actor is left of the screen or right.

Also in the actor I have a rule that says if the actor's x is lower than or equal to 100, change velocity to direction 0 (right) and increase acceleration, so that it starts moving. I have an opposite rule set to if the self.x is equal or greater to 650.

The only way I can get this to work is if the start_x actually has the actor visible on the screen. Otherwise the behaviours just don't kick in. I've never come across this behaviour, where actors seem to ignore rules and behaviours if they're not on the visible screen. Don't suppose anyone might know what's happening?

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    One possible reason for this is if your actor goes too far off screen and is actually deleted. Try adding a timer set to every 1 second with a Log Debugging Statement with self.Position.X and watch the Debugger window to see if the actor is where you think it should be.

    Beyond that, I'd have to see your exact rules to know why it's not functioning correctly.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • imjustmikeimjustmike Member Posts: 450
    Ah I did not know that! Good shout on the debug behaviour, I really don't use that enough! Is there any documentation anywhere on what the parameters are for actors being deleted?

    I'll give it a go tonight, though I'd be surprised if that was the case as I've had actors be a lot further off screen in other builds without any issue.
  • JSprojectJSproject Member Posts: 730
    @imjustmike - "One possible reason for this is if your actor goes too far off screen and is actually deleted." that @tatiang wrote is a likely reason. In my own testing (0.10.4.1 adhoc) I have seen that actors do not have to be very far off the screen at all in order to be deleted. What's worse is that it can look/play fine at first when running the app but as memory builds up and you go back to a scene where you have actors of screen then they can be automatically deleted and break your logic.

    Two ways of handling this:
    1. Increase your scene size and place those actors so they are outside the screen/camera area but inside the scene.
    or
    2. Minimize the size of those actors, place them so they fit within the grey area outside of your current scene size and add rules to those actors that changes their size, to their correct values, when that scene starts.


  • imjustmikeimjustmike Member Posts: 450
    So it turns out that I had been looking in the wrong direction - there was a needless collision rule that was stopping the actors from moving, they weren't being deleted at all. Huge and MASSIVE and ENDLESS thanks goes to @tatiang for taking a look and solving the problem :)

    @JSproject - I've been using double scene sizes for a while for my menu systems, I'm pretty OCD so like having the room to lay things out nicely, but I really like the idea on using rules to change actor sizes - could even have them interpolate up to the right size, might be a nice effect.
  • JSprojectJSproject Member Posts: 730
    @imjustmike great :)
    Yeah, interpolate to correct size produce a nice effect in some cases.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You're welcome! :)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.