Circular Movement

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

Wonolf
Koopa
Koopa
Posts: 16
Joined: Wed Oct 30, 2019 2:45 pm
Flair: Puyo Puyo Trainee

Circular Movement

Postby Wonolf » Sat Feb 08, 2020 9:18 pm

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

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: Circular Movement

Postby Chilly14 » Sat Feb 08, 2020 10:45 pm

change v.speedX to 1?

Ace
Volcano Lotus
Volcano Lotus
Posts: 579
Joined: Sun Mar 23, 2014 4:50 pm
Pronouns: he/him

Re: Circular Movement

Postby Ace » Sat Feb 08, 2020 10:49 pm

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?

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: Circular Movement

Postby Chilly14 » Sat Feb 08, 2020 11:02 pm

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

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Circular Movement

Postby Hoeloe » Sun Feb 09, 2020 12:08 am

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.

Wonolf
Koopa
Koopa
Posts: 16
Joined: Wed Oct 30, 2019 2:45 pm
Flair: Puyo Puyo Trainee

Re: Circular Movement

Postby Wonolf » Sun Feb 09, 2020 1:45 pm

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


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari