How to make ideal circle Path2D in simple way?

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

How to make ideal circle Path2D in simple way? Manual adjusting Path2D is annoying.

What are you trying to accomplish? There may be an easier solution, depending on what you are planning to use the circular path for.

kidscancode | 2018-10-03 20:59

I would like to make space ship movement around planet

wojtasss | 2018-10-03 21:23

:bust_in_silhouette: Reply From: kidscancode

If all you want is circular movement, this is far easier done by parenting your “ship” to a Node2D and rotating it.

– Ship

extends Node2D

var speed = 2  # rotation speed (in radians)
var radius = 100  # desired orbit radius
func _ready():
    $Ship.position = Vector2(radius, 0) # desired orbit radius

func _process(delta):
    rotation += speed * delta

Quite nice and simple solution, but what if I want after press space, spaceship go straight forward in direction that was during space press?

wojtasss | 2018-10-04 17:18

You know the direction (the rotation of the node) so stop the rotation and apply a velocity in that direction. If you have multiple planets you can have them “capture” the ship by changing the ship’s parent. It’s hard to be much more specific because it really depends on how you’re implementing movement and what kind of body you’re using for the ship.

kidscancode | 2018-10-04 19:03

Yes you are right, thanks for help! I am new one here, have some experience with game dev, but I was using Corona SDK, Godot development flow is very different still learn!

wojtasss | 2018-10-04 19:32

Thank god, it saves me from the hell of physics

dethland | 2020-11-27 15:12