Page 1 of 1

Circular Movement

Posted: Sat Feb 08, 2020 9:18 pm
by Wonolf
Hello! I'm trying to make a custom npc that moves in circles. I'm using cos for x axis and sin for y axis, but I don't know why my npc draws an ellipse
instead of a circle, being the y radius higher than x's. Am I missing something?

Here's the code:

Code: Select all

if not Layer.isPaused() or not Defines.levelFreeze then
		ballTimer = ballTimer + 1
		
		v.speedX = math.cos(ballTimer * math.pi / 180) *  0.75	--Horizontal
		v.speedY = math.sin(ballTimer * math.pi / 180) *  1		--Vertical

Re: Circular Movement

Posted: Sat Feb 08, 2020 10:45 pm
by Chilly14
change v.speedX to 1?

Re: Circular Movement

Posted: Sat Feb 08, 2020 10:49 pm
by Ace
I'm not too sure what you're asking; you seem to understand that you're getting an ellipse instead of a circle because you're multiplying X by 1 and Y by 0.75. So what's the question?

Re: Circular Movement

Posted: Sat Feb 08, 2020 11:02 pm
by Chilly14
Chilly14 wrote:
Sat Feb 08, 2020 10:45 pm
change v.speedX to 1?
Got some code for you to try:

Code: Select all

if not Layer.isPaused() or not Defines.levelFreeze then ballTimer = ballTimer + 1 v.speedX = math.cos(ballTimer * math.pi / 180) * 1 --Horizontal v.speedY = math.sin(ballTimer * math.pi / 180) * 1 --Vertical

Re: Circular Movement

Posted: Sun Feb 09, 2020 12:08 am
by Hoeloe
Wonolf wrote:
Sat Feb 08, 2020 9:18 pm

Code: Select all

if not Layer.isPaused() or not Defines.levelFreeze then

This should definitely be "and" here.

Re: Circular Movement

Posted: Sun Feb 09, 2020 1:45 pm
by Wonolf
I tried all of the above but the problem is still there.
Here's a gif showing the current npc movement. The first number shown is the X speed and the other is the Y speed.
For the people who didn't understand in the main post, I want that ball to orbit in a circle around that block.

Image