Unable to animate p

I’m clearly doing something wrong, I’m trying to animate a object up and down, should be simple enought but can’t seem to figure out why it’s not working for me: Babylon.js Playground

Just want to animate it up and down from its current position…

Hi @i73

Just a missing new

https://www.babylonjs-playground.com/#PMN7K0#1

1 Like

Thanks Cedric, should have been a little more specific with the actual vector, I need it to move up from it’s original pos, why won’t this work: https://www.babylonjs-playground.com/#PMN7K0#2

Also is there a way to go up and down out of the box or would I have to make another animation, I tried all the Babylon loop enums ?

I find it is best to work with creating keys directly. Your last one didn’t work because whenever you set a variable to an objects position, and then change that variable, you also are changing that objects position as well. To fix that, do .position.clone().

However, just to get something bobbing up and down, create keys to do it imo.
https://www.babylonjs-playground.com/#PMN7K0#3

1 Like

Ah, I didn’t know it updates the reference, thanks so much!