x = (object position x – wanted position x)*-1
y = (object position y – wanted position y)*-1
I bloody hate math mate. makes my head hurt.
Only need someone to create a workflow function with the calculations & then your all good mate.I bloody hate math mate. makes my head hurt.
Haha, i guess that's why it would be handy to also have Lua absolute position option for moving objects.
Yeah that's the issue. The acion part is nice but you can't use it dynamically with values.Ah ok. I kind of guessed that the -1 value was for inversing the current value.You don't actually need to check it mate. The *-1 part will take care of that.
Let's say your object x posistion is 500, you wanted to move to 700 then
(500 - 700)*-1 = 200
If you would wanted to move to lower value like 150 then
(500 - 150)*-1 = -350
function moveObj(obj, x, y, delay, easing)
obj = game.CurrentScene.SceneObjects[obj]
-- + --
obj:to(delay, { ObjectOffset = {x = (obj.ObjectPosition.x - x) * -1, y = (obj.ObjectPosition.y - y) * -1} }, easing)
end
moveObj("rock", 500, 300, 1000, easeQuintOut)
moveObj("rock", Values["example1"].Int, Values["example2"].Int, 1000, easeQuintOut)
Well you gonna have to use ObjectPosition for that instead. The offset is gonna be 0 until you move the object.Aye, you're right mate. Wrote it out quickly without thinking about it too much. Will edit the example. No, if you are moving to specific coordinates then there's no need to calculate current offset. The default object position always remains the same value.I guess it's getting more complicated when you want to move the object more than once since the object position won't get updated.I suppose you would have to check if there's any offset, if not use the method you wrote if yes then you would also need to add the current offset to the position.
If the object is on x 500, you will offset it by 200 to get it on x 700 then you need to use the new position instead no? If you would want it to move more than once in a single scene visit.ObjectPosition is always the default position value. ObjectOffset is an offset value based from the default position. So if you want to move to another specific x,y coordinate then you can just redo your calculations on the default ObjectPosition again. Basing it on the offset complicates matters & it will move from the current offset value to the new value - or at least it should.