Changing object layer position in the scene

  • #1, by YourichiganThursday, 05. May 2016, 14:55 4 years ago
    Hello there!

    I have a problem i can't quite solve and maybe i am missing something simple.

    In a scene i need to change on ordering of displayed objects depending on player actions. For example, imagine a player is painting, if player clicks red button (on screen), an object (a splash of red paint) is displayed. If player then pressed green button, an object (a splash of green paint) should be displayed on top of the red splash (with parts of red splash still visible underneath).

    I want it to be indifferent to the ordering of buttons pressed (red first or green first). But i always get the color, that is higher in scene ordering in visionaire, on top.

    I tried doing this method, but it does not seem to be working in my case.

    So, can i change a layer order of objects in a scene in game to change their visibility order?

    Newbie

    12 Posts


  • #2, by sebastianThursday, 05. May 2016, 15:26 4 years ago
    try this:

    getObject('Scenes['my_scene'].SceneObjects['my_object_name']'):setValue(VObjectCenter, my_center_number)
    1
    2


    replace the "my_ ..." strings with the names of your scene/object/value

    Thread Captain

    2337 Posts

  • #3, by afrlmeThursday, 05. May 2016, 15:36 4 years ago
    Yeah I think the issue is that it requires the scene to be reloaded for the new value to take effect. Technically you can adjust the index value by adjusting the objects offset value, but you would need to add the image as an animation so you can counter the offset value & prevent the image position from moving too. When you change the offset value it should adjust the object center value too - unconfirmed though.

    Your other alternative would be to create multiple scene objects & control which should be displayed via conditions.

    Imperator

    6842 Posts

  • #4, by YourichiganThursday, 05. May 2016, 15:52 4 years ago
    @Sebastian.204 Actually it is basically the same script i linked in my question) But maybe i am using it wrong.
    Here is a basic actionlist:

    Player pushes the button.
    I check if there was any paint already.
    If there is paint I set object center (of current splash to be applied after button pressed) to 1000
    Reload the scene.
    And make this object visible.

    The problem is, it still does not change visibility of objects in the game. It always draws the "paint object" that is higher in hierarchy in Scene objects view of editor.

    @AFRLme
    You mean i will have to create all the combinations of objects? That is "only red paint object", "only green paint object", "red first green second object" and "green first red second object"?

    Newbie

    12 Posts

  • #5, by afrlmeThursday, 05. May 2016, 19:16 4 years ago
    What you have just written is confusing the hell out of me. It's like some kind of tongue twister. Red lorry, yellow lorry...

    It's a bit hard to know exactly what you have in mind from what you've written alone as I'm having a hard time visualizing it in my mind. You could create a few objects & add an animation to each of them that contains a different color in each frame & one frame that has a transparent image. You could use Lua script to force which frame to loop. If you set up a loop you could easily control which frame to play by having it check some values & then update the animation frames based on said values.

    P.S: I'm going to guess that what I've written means absolutely nothing to you & makes no sense at all? Am I right? This is the problem when trying to convey something with text only.

    Imperator

    6842 Posts

  • #6, by YourichiganFriday, 06. May 2016, 15:10 4 years ago
    No, actually i think i get the idea of the method you described, and will try it today! Will post results if it works.

    Also sorry for my convoluted question, i have a problem with over-complicating things sometimes)

    Newbie

    12 Posts

  • #7, by afrlmeFriday, 06. May 2016, 16:00 4 years ago
    Don't we all? grin

    Imperator

    6842 Posts

  • #8, by YourichiganWednesday, 11. May 2016, 16:56 4 years ago
    Ok, forgot to post back(

    I have found a solution to the task. Thanks AFRLme for pointing me in right direction.

    All i had to do eventually was to use one object in the scene, and all other objects (whose layers i wanted to interchange) were single frame animations in this object. And when i use "Play animation" action in scene, it displays the needed sprite (paint splash object in my case), and any other "Play animation" action shows new animation on top of the other, no matter their index order in the scene, only the order of activation of "Play animation" action is important.

    Newbie

    12 Posts

  • #9, by sebastianWednesday, 11. May 2016, 16:58 4 years ago
    Wow... Good to know . Could be very useful in other cases smile

    Thread Captain

    2337 Posts

Write post