Move object action part - Make it persistent

  • #1, z dionousTuesday, 21. March 2017, 13:45 hodinky 8 years ago
    Hello to all,

    I'm using the Move object action part to move an object in a scene. However, every time i return to the scene the object returns to its original position.

    I guess this is the way Move object works or is it a bug?

    What would be the best way to make the new position permanent? I guess the obvious is to make a new duplicate item along with a new positionioning, but just in case i'm missing smth here.

    Thanks!

    Fanoušek fóra

    246 Posts


  • #2, z ke4Tuesday, 21. March 2017, 14:11 hodinky 8 years ago
    That might be a bug. I believe the moved objects stayed on the new position before. What version are you using? Just tested in Vis 5, so don't know about 4.2.5

    Zabiják klíčů

    810 Posts

  • #3, z afrlmeTuesday, 21. March 2017, 14:21 hodinky 8 years ago
    It's an offset & not the actual object position. If you want to store it then you need to store the x,y position inside of a couple of VS values.

    1. create a couple of values inside of the current scene (or alternatively in the values tab of the relevant object - take in mind that scene values are easier to access). Give them unique yet relevant names; something along the lines of rock_x & rock_y. Set both values to 0 as the default value.

    2. after using the move object action part add a pause action for the duration it takes to move the object, then create an execute a script action part & add this to it (change the names of values & objects to suit...
    game.CurrentScene.SceneValues["objectname_x"].Int = game.CurrentScene.SceneObjects["objectname"].ObjectOffset.x
    game.CurrentScene.SceneValues["objectname_y"].Int = game.CurrentScene.SceneObjects["objectname"].ObjectOffset.y


    3. create an at begin of scene action under scene actions if you don't already have one. You can either create a called by other action block & call that in the begin of scene action or you can directly add the script to the at begin of scene action - up to you; either way you need to create an execute a script action part & add something like this to it...
    game.CurrentScene.SceneObjects["objectname"].ObjectOffset = {x = game.CurrentScene.SceneValues["objectname_x"].Int, y = game.CurrentScene.SceneValues["objectname_y"].Int}
    

    & that should automatically offset your object each time scene is reloaded.

    P.S: @ Ke4: I'm not sure if they are supposed to be remembered. I rarely used the offset action parts. Always preferred moving animations instead as I've not needed to offset the objects polygons yet, so far...

    Imperátor

    7285 Posts

  • #4, z dionousWednesday, 22. March 2017, 09:24 hodinky 8 years ago
    Yes it seems it's just a temp offset setting (Using 4.25)

    AFRLme thanks for the nice solution, should work but a strange thing is happening:

    Even if i set the script to execute when the scene begins or called by another action it only executes the first time. So i enter the scene the first time, the object is moved ok. For any subsequent entrances in the scene, the object will rest in its original position, really weird.

    Fanoušek fóra

    246 Posts

  • #5, z afrlmeWednesday, 22. March 2017, 10:59 hodinky 8 years ago
    Can you post a screenshot of your at begin of scene action please?

    Imperátor

    7285 Posts

  • #6, z dionousWednesday, 22. March 2017, 11:51 hodinky 8 years ago
    Sure, pls see attached.

    To make things simpler and for testing purposes, i have used explicit values for the ObjectOffset x y values.

    Fanoušek fóra

    246 Posts

  • #7, z afrlmeWednesday, 22. March 2017, 12:09 hodinky 8 years ago
    This resets it back to that each time you load the scene, yes? You have to remember that this is offset. Lua ObjectOffset doesn't move the object to the specified coordinates like the move to action part but instead offsets the object from its default position like the move object action part instead.

    One thing I really would recommend (if the positions you are moving the object to are predetermined positions rather than random) would be to create duplicate scene objects of the relevant scene object & move the image/animation & interaction polygon to where you need it. You should also assign some conditions to the properties tab. That way you can determine which should be shown immediately on scene load based on which condition is true. If you move an object then after it's moved you toggle the conditions based on where it was moved to.

    Imperátor

    7285 Posts

  • #8, z ke4Wednesday, 22. March 2017, 12:10 hodinky 8 years ago
    @AFRLme: Yeah you're right. I do now remember that i was trying to move some object like that or something and i was using duplicated object for the new position. I don't know why it's not remembered though or why there's no Lua option to move object on a absolute position.

    Zabiják klíčů

    810 Posts

  • #9, z dionousWednesday, 22. March 2017, 12:17 hodinky 8 years ago
    @AFRLme: Yes, it resets back each time the scene loads which is weird. (True it is offset value, not absosulte position)

    Agree that for now, the best option is duplicate item.

    Agree also with ke4 that being able to move an object to an absolute position would be a handy option in VS.

    Fanoušek fóra

    246 Posts

  • #10, z afrlmeWednesday, 22. March 2017, 12:17 hodinky 8 years ago
    @AFRLme: Yeah you're right. I do now remember that i was trying to move some object like that or something and i was using duplicated object for the new position. I don't know why it's not remembered though or why there's no Lua option to move object on a absolute position.
    The 2 move object action parts are the same. Alex created the "move to" action part because (I think myself & a few others complained about it not being very intuitive). One offsets from default position which is kind of confusing & the other moves to the specified coordinates - it's the same function really except Alex added some math calculations into it I think to make it move to specified coordinates instead of offsetting.

    You can do that with Lua script one too, but I have never successfully managed to get the calculation right. The only way I managed to get it to work was by leaving the object in the top left corner of the scene to begin with so that the default position was 0,0. That makes it easy to offset to specified coordinate as whatever you set is where it will go because 0 + whatever = whatever you specified. wink

    Imperátor

    7285 Posts

  • #11, z ke4Wednesday, 22. March 2017, 12:35 hodinky 8 years ago
    Yep you could do something like this i think

    x = (object position x – wanted position x)*-1
    y = (object position y – wanted position y)*-1

    Zabiják klíčů

    810 Posts