Hi, I have a spherical planet with a player and an enemy. The enemy has a parent that act as a pivot. To move the enemy I rotate the pivot and so the enemy rotate following the surface of the planet.
Now, I would like to move the enemy in an alternating pattern (i.e. move for a bit, then stops for some time, and then move again), I found a bad and non-elegant solution that works more or less like this:
IF enemy moved for less then threshold:
move for another bit
moved distance+=bit
ELSE:
moved distance=0
wait
This actually works but it’s really impractical since with more enemies I should save for every enemy the moved distance, the time to the new movement …
I don’t know which could be the better solution to solve my problem. i took a look at animations,and there are nice ways to set up keyframes, but it seems that you animate a property of the object, while I use the function rotate.
Also in the future I would like to use the function locallyTranslate() while executing the animation.
Can someone help me?
Here is a playground with a minimal setup and my (horrible) solution:
https://playground.babylonjs.com/#JKDD0G#1