how to make an enemy move

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Yamz

como seria el codigo para el movimiento de un enemigo (“KinematicBody2d”)

:bust_in_silhouette: Reply From: ItsYoBoi

The way I make the enemies move in my game is by using an animation player. I can try to walk you through using one.

1)Add the animation sprite to your scene.
2)There should be a button on there that says “Animation”. Click that, click new, and then give the animation a name (name doesnt matter at all).
3)On right side of the little bars that appears, you should see an arrow (pointing to the right) thats says “A+”. If you want the enemies to move when the scene starts, click that on.
4)You should also see a bar that says “Add Track”. If you follow this bar to the very end of it you should see two arrows that go in a circle. Click this little button (so enemy movements loop)
5)Make the the little blue line on the “add track” is on 0
6)Nearby the two arrows that go in a circle you should the number “1”. This little section is important because this can affect how fast and how many different ways your enemies can move. I recommend changing the “1” to “4” and test that out.

Lets start animating your enemies

7)With the little animation bar at the bottom of the screen still up, Click on the enemy that you want to move. Hover over to the inspector tab and find transform. Open that. Now before we animate the enemy, move the enemy to the place you want the enemy to start at. Under the transform tab, next to “position” you should see a little key. Click that key
8)After you click the key, click create.
9) Now move the blue line on the “track” created for the enemy (animation tab bar) and move it over to “2”. Now move your enemy to the place you want your enemy to stop moving at. Now hit the key next to position again.

If you followed all of my steps, your enemy should be moving now