[ 8 posts ]  Reply to topicPost new topic 
Author Message
 [zz]
 Post subject: Trying to get a sideways figure eight motion without paths
PostPosted: Sat May 13, 2017 2:37 pm 
User avatar
I, Papyrus, am awesome!
Member
[*]
[*]
[*]
So I'm trying to make a projectile move in a sideways figure eight motion without having to use paths (please don't ask why), but for some reasons, I never can seem to get the projectile movement right...
Create Event:
Code:
/* Movemement */
parent      =   0;
sinewave    =   0;
hortime    =   5;
hordir      =   1;


Step Event:
Code:
if (hordir = -1 && hortime > -10){
    hortime += -0.5;
} else if (hordir = -1 && hortime <= -10){
    hordir = 1;
} else if (hordir = 1 && hortime < 10){
    hortime += 0.5;
} else if (hordir = 1 && hortime >= 10){
    hordir = -1;
}

sinewave += 5;
y = ystart+lengthdir_y(40,sinewave);
hspeed = -image_xscale*(hortime/2);


Anyone knows what I'm doing wrong? I would be glad if someone could help me there. Thanks in advance!

_________________
My games:
Spoiler:

What I also support:
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: Trying to get a sideways figure eight motion without pat
PostPosted: Sat May 13, 2017 4:59 pm 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
Syntax: [ Download ] [ Hide ]
Using gml Syntax Highlighting
wave = (wave + 0.2) % (4 * pi);

ref_x += hspeed;

x = ref_x + cos(wave * 0.5) * 128;
y = ystart + sin(wave) * 128;

Spoiler:

Is this what you want?

_________________
Image

Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [zz]
 Post subject: Re: Trying to get a sideways figure eight motion without pat
PostPosted: Sun May 14, 2017 5:44 am 
User avatar
I, Papyrus, am awesome!
Member
[*]
[*]
[*]
Almost, but not quite. It was supossed to go back and forth and, like, literally draw a sideways figure eight.

That might sound weird as a projectile, but don't worry, it all will make sense eventually. :3

_________________
My games:
Spoiler:

What I also support:
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: Trying to get a sideways figure eight motion without pat
PostPosted: Sun May 14, 2017 5:52 am 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
Ah, in that case just remove the hspeed part and replace ref_x with xstart or something.

_________________
Image

Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [zz]
 Post subject: Re: Trying to get a sideways figure eight motion without pat
PostPosted: Sun May 14, 2017 6:15 am 
User avatar
I, Papyrus, am awesome!
Member
[*]
[*]
[*]
Thanks. Never thought Game Maker had proper sin/cos functions tbh, so I was searching for ways of emulating it... :whoops:

_________________
My games:
Spoiler:

What I also support:
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Trying to get a sideways figure eight motion without pat
PostPosted: Sun May 14, 2017 10:44 am 
User avatar
Always have a Shy-Guy in your avatar
Administrator
[A]
[S]
[W]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

Pretty much all programming languages (including GML) have trigonometric functions.

_________________
Course clear! You got a card.

Image
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: Trying to get a sideways figure eight motion without pat
PostPosted: Sun May 14, 2017 10:50 am 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
lengthdir_x and lengthdir_y are basically just alternate versions to sin and cos, too.

lengthdir_x(len, dir) is the same as cos(degtorad(dir)) * len
lengthdir_y(len, dir) is the same as -sin(degtorad(dir)) * len

Correct me if I messed up the maths

_________________
Image

Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Trying to get a sideways figure eight motion without pat
PostPosted: Sun May 14, 2017 1:05 pm 
User avatar
Kootie Patootie
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
If you just made a perfect figure eight movement, then you could use
Code:
x += 1;

to get the net movement without complex maths.

_________________
Image
My mains
 
Top
Offline 
 User page at mfgg.net
 
« Previous topic | Next topic »
Display posts from previous:  Sort by  
 [ 8 posts ]  Reply to topicPost new topic 


Who is online

Users browsing this topic: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group