Is it possible to update Z coordinate during go.animate?

For my 2d top-down tile map project i need to change object z coordinate (index) for depth simulation. For that purpose i use Y coordinate of each object on the map and map it to the range from 0 to 1. It works as expected so far.

The problem is - i can not update Z coordinate for objects currently updated by go.animate. This lead to an issue where animated object will overlap other objects on it’s movement path until animation is complete.

For example if i move an to some destination point

  destination, go.EASING_LINEAR, duration, 0, 
  function (self)

Then updating it’s z index during update will not work

function update(self, dt)
  local position = go.get_position()
  position = map_helper.z_index_for_y(position.y)

It looks like go.animate makes changes after game object update call and overrides position property.

What i looking for is some sort of callback for go.animate or post_update where i can modify animation result.

I can move objects manually inside update callback obviously, but this will introduce complexity since i really do not want to loose ability to use easing functions and handle precision issues manually.

you don’t need to update function at all. just set
destination.z = map_helper.z_index_for_y(destination.y)
before call animation function.


Ok. that was a waste of two hours. Thanks, it works as expected.

You could also animate “position.x” and “position.y” separately, which would leave position.z untouched.

1 Like