# Animate Y coord

**URL:** <https://forum.defold.com/t/animate-y-coord/76260>\
**Category:** Questions\
**Created:** [March 10, 2024, 7:37pm UTC](https://forum.defold.com/t/animate-y-coord/76260 "2024-03-10T19:37:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ainonovo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ainonovo/32/27068_2.png) [@ainonovo](https://forum.defold.com/u/ainonovo)\
**Post date:** [March 10, 2024, 7:37pm UTC](https://forum.defold.com/t/animate-y-coord/76260/1 "2024-03-10T19:37:14Z")

</div>

i use rendercam and this code for X axis animation standart 2d coord to 3d  
all animation build with [panthera](https://insality.github.io/panthera-editor/editor/)

```lua
	local node_body = global_.go_robots[message.uid].body.s2
	
	local node_body_position = go.get(node_body, "position")
	local sc = rendercam.world_to_screen(node_body_position, false, false)
	
	sc.x = sc.x + 15 -- **+ 15px to right**
	local wd = rendercam.screen_to_world_2d(sc.x, sc.y, false, sc.z, false)

	go.animate(node_body, POSITION_X, go.PLAYBACK_ONCE_FORWARD, wd.x, gui.EASING_OUTSINE, 1 / speed)

```

Seems to work correctly both forward and backward.  
**But if I try Animate Y coord - GO always move down (((**

```lua
	local node_body_position = go.get(node_body, "position")
	local sc = rendercam.world_to_screen(node_body_position, false, false)
	sc.y = sc.y + 5 -- **even if I subtract or add**
	local wd = rendercam.screen_to_world_2d(sc.x, sc.y, false, sc.z, false)

	go.animate(node_body, POSITION_Y, go.PLAYBACK_ONCE_FORWARD, wd.y, gui.EASING_OUTSINE, 0.25 / speed, 0, function()
        end)

```

---

<div class="post-metadata">

**Author:** ![Insality](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/insality/32/39737_2.png) [@Insality](https://forum.defold.com/u/Insality)\
**Post date:** [March 13, 2024, 10:45am UTC](https://forum.defold.com/t/animate-y-coord/76260/2 "2024-03-13T10:45:26Z")

</div>

Hello! Can you provide more information and examples?

For the code you provided all should work correctly, don’t see any issues here

---

<div class="post-metadata">

**Author:** ![ainonovo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ainonovo/32/27068_2.png) [@ainonovo](https://forum.defold.com/u/ainonovo)\
**Post date:** [March 13, 2024, 12:18pm UTC](https://forum.defold.com/t/animate-y-coord/76260/3 "2024-03-13T12:18:22Z")

</div>

Thanks for answer ))

I make this

![Video_2024-03-13_145803](https://defold-forum-bucket.nbg1.your-objectstorage.com/original/3X/2/a/2ae8e4ce4b208a8fba2ba159ba4d3f7540982296.gif)

and get this code for body - head and legs is a childs of body

```lua
go.animate(node_body, POSITION_X, go.PLAYBACK_ONCE_FORWARD, node_body_position.x + 15, gui.EASING_OUTSINE, 1 / speed)

```

**but i use rendercam**

![Video_2024-03-13_150055](https://defold-forum-bucket.nbg1.your-objectstorage.com/original/3X/8/d/8df4bf4d281e47a159ccb92e9cf42cf2d41cb9a0.gif)

and work normal only this code for body

```lua
	go.animate(node_body, POSITION_X, go.PLAYBACK_ONCE_FORWARD, node_body_position.x + (direction and 15 or -15) / 15, gui.EASING_OUTSINE, 1 / speed)

	go.animate(node_body, POSITION_Y, go.PLAYBACK_ONCE_FORWARD, node_body_position.y + 5 / 20, gui.EASING_OUTSINE, 0.25 / speed, 0, function()
		go.animate(node_body, POSITION_Y, go.PLAYBACK_ONCE_FORWARD, node_body_position.y, gui.EASING_OUTSINE, 0.25 / speed)
	end)

```

all works fine, but i use divider / 15 for x and / 20 for y coords. Else all fly away ((  
I think this is due to incorrect calculation of the z and y coordinates of the perspective.  
Perhaps you know a solution to the problem?

---

<div class="post-metadata">

**Author:** ![Insality](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/insality/32/39737_2.png) [@Insality](https://forum.defold.com/u/Insality)\
**Post date:** [March 13, 2024, 2:13pm UTC](https://forum.defold.com/t/animate-y-coord/76260/4 "2024-03-13T14:13:16Z")

</div>

> [@ainonovo](#):
>
> Perhaps you know a solution to the problem?

I can only a guess that’s wrong, since I don’t have a full context. It’s definitely not relative to rendercam or Defold engine. Something in your node setup or animation usage, please revise all thing slowly.

Is animation started correctly and you don’t start the animation every frame?

How these bodies are fly away? these dividers are strange way to fix this btw

Is parent for animation nodes flipped? It can cause wrong direction of some animations inside

---

<div class="post-metadata">

**Author:** ![ainonovo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ainonovo/32/27068_2.png) [@ainonovo](https://forum.defold.com/u/ainonovo)\
**Post date:** [March 13, 2024, 2:51pm UTC](https://forum.defold.com/t/animate-y-coord/76260/5 "2024-03-13T14:51:40Z")

</div>

everything works correctly. Just in the 3d world + 20px on the Y axis != + 20 px for 2d (((
