# Circular Movement

Attention Topic was automatically imported from the old Question2Answer platform.
Old Version Published before Godot 3 was released.

Hi everyone!!

I need to create a script to make the move of an enemy. The enemy is a seagull. The seagull flies with circular and continuous motion. I need to use move function because the seagull needs to detect collisions. I dont know if in godot I can use something similar to euler function like Unity 5 in this case.

Ideas??

Thanks for any help

First you need to declare circular movement. Like:
EDITED:

``````var speed = 1
var CircularMovement = Curve2D.new()
var r = 100
var pos = Vector2(200,200)
CircularMovement.set_bake_interval(1)
``````

Then you should save somewhere position in baked_points, eg.:

``````var bppos = 0
``````

If you can use `move_to()` instead of `move()`, everything will be easier. If so, use:

``````func _fixed_process(delta):
if bppos + delta*speed >= CircularMovement.get_baked_points().size():
bppos += delta*speed - CircularMovement.get_baked_points().size()
else:
KinematicBody2D.move_pos(CircularMovement.get_baked_points()[round(bppos)])
bppos += delta*speed
``````

SHOULD work, but not best solution.

This is bad due to ignoring the delta value of the fixed process function.

timoschwarzer | 2017-07-12 23:47

Yup, that’s true. It should be something like this:

``````KinematicBody2D.move_pos(CircularMovement.get_baked_points()[round(bppos)])
bppos += delta*1
``````

And o/c condition: if bppos is at the end of curve; then pbpos = 0
Thanks for caution

Kamil Lewan | 2017-07-13 10:39

Thanks for editing! Now this should work find on any computer / framerate.

timoschwarzer | 2017-07-13 10:56

Many thanks I will try it

pasuva | 2017-07-17 07:47

Hey, thanks! That was really helpful

Do you know how can I change the points to get an elliptical orbit instead of a circular one?

hiulit | 2019-04-18 14:13

I know this has been answered, but I found a simpler solution while searching around that I think might be useful for someone.

``````var RotateSpeed = 5
var _centre
var _angle = 0