GMS 2 how to make floating enemies ?

M

Mort(e)

Guest
i just recently started using GMS2 and im trying to make a floating object but i can't figure out how to make it have wall collision and float at the same time. oh and tbh im a nood at coding just recently started on coding school so i don't know **** about coding. ¯\_(ツ)_/¯ (oh the game im making is a 2D scroller)
 
Last edited by a moderator:

samspade

Member
What attributes of floating do you want? Do you mean you want it to fall until a certain point above the ground? Do you mean you want it to be set at a certain point and bob up and down? Do you mean you want it to be stationary until something lands on it and then you want it to move? Can anything land on it or does it just deal contact damage?

What is coding school?
 
M

Mort(e)

Guest
What attributes of floating do you want? Do you mean you want it to fall until a certain point above the ground? Do you mean you want it to be set at a certain point and bob up and down? Do you mean you want it to be stationary until something lands on it and then you want it to move? Can anything land on it or does it just deal contact damage?

What is coding school?
what im looking for is just an enemy that does little bobs up and down. i have something i found on other threads but they mess with the gravity and collision detection so the enemies go through the walls. so yeah that's sort of the thing i want.

thanks dude
oh my college has a special department for gamedevs. i just call it coding school

"half of the message got erased, but i fixed it "
 
Last edited by a moderator:
M

Mort(e)

Guest
What attributes of floating do you want? Do you mean you want it to fall until a certain point above the ground? Do you mean you want it to be set at a certain point and bob up and down? Do you mean you want it to be stationary until something lands on it and then you want it to move? Can anything land on it or does it just deal contact damage?

What is coding school?
Quite Curious!!! Mort(e) what kind of games do you hope to make in the future? :)
im working on a 2d scroller "Arc" (sort of a metrovenia type game) but to be honest i feel that GMS2 is just a starting point for me, hopefully ill learn how to use other game engines or C+. i want to make gameDev my profession.
 
GM is Awesome though & was the half my team got into game-dev in the first place about 10 years ago, as you can see results in a matter of hours instead of days, months or even years.
 
M

Mort(e)

Guest
oh lol no problem at all, I´m not going to help you with that :) Im building a Multilayer & an MMO with a 4 man team using C# :)
That sound awesome dude ! hope you guys makes a hit, good luck with that mate ᕙ(⇀‸↼‶)ᕗ and yeah im just staring with GM so i have to learn a lot and in the future use C#
 
That sound awesome dude ! hope you guys makes a hit, good luck with that mate ᕙ(⇀‸↼‶)ᕗ and yeah im just staring with GM so i have to learn a lot and in the future use C#
Thanks bro :) I appreciate it! btw I did want to help you with GM, but not on this specific project :) Later, perhaps I´d be willing to provide some serious advice on transitioning to a deeper level of code. :) I´m not a Lead Programmer on my team though, I´m an Organizer, Artist, PR & theoretical programmer, so I have a bit to draw from, should you be interested in reaching out at some point ^^
 
M

Mort(e)

Guest
Thanks bro :) I appreciate it! btw I did want to help you with GM, but not on this specific project :) Later, perhaps I´d be willing to provide some serious advice on transitioning to a deeper level of code. :) I´m not a Lead Programmer on my team though, I´m an Organizer, Artist, PR & theoretical programmer, so I have a bit to draw from, should you be interested in reaching out at some point ^^
hell yeah man, but just for precociousness i would like to see if you're legit and for this for not to be a scam, i would like to see some proof. you know just to make sure. :] you get me right ? but yeah i might consider the offer!
 
hell yeah man, but just for precociousness i would like to see if you're legit and for this for not to be a scam, i would like to see some proof. you know just to make sure. :] you get me right ? but yeah i might consider the offer!
Search "Citizens of Laniakea" on Youtube. Then Search "Pulsar Regions Project Moon" & last but not least, for our latest Give-Away GM game(made in like 8 hours lol) Search "Frontline Saturn" on youtube.
 
....To actually answer the question :p

Just use a sine wave while drawing the floating entity. Don't change anything in regards to movement or collisions; the game will still treat this character as being static at the core, but the drawing will function a bit differently to provide the visual desire.

float_dis will be how wide the character will travel when floating.
float_spd will be how fast it will move within this arc.
Code:
draw_sprite(sprite,index,x,y+sin(float_spd)*float_dis);
float_spd += whatever;
 
M

Mort(e)

Guest
Search "Citizens of Laniakea" on Youtube. Then Search "Pulsar Regions Project Moon" & last but not least, for our latest Give-Away GM game(made in like 8 hours lol) Search "Frontline Saturn" on youtube.
alright seems pretty convincing :] so yeah thanks for the offer ill stay in touch maybe later we can have a conversation about that transition into deeper coding levels ! so i really appreciate the help
 
M

Mort(e)

Guest
....To actually answer the question :p

Just use a sine wave while drawing the floating entity. Don't change anything in regards to movement or collisions; the game will still treat this character as being static at the core, but the drawing will function a bit differently to provide the visual desire.

float_dis will be how wide the character will travel when floating.
float_spd will be how fast it will move within this arc.
Code:
draw_sprite(sprite,index,x,y+sin(float_spd)*float_dis);
float_spd += whatever;
so should i put this in a draw event ? and leave the collision alone ?


float_dis // float_spd /// and are this just variables ? so should i put them in a create event ?
 
Z

Zachary_tzy

Guest
so should i put this in a draw event ? and leave the collision alone ?


float_dis // float_spd /// and are this just variables ? so should i put them in a create event ?
Edit: Sorry my advice was mistaken!
 
Last edited by a moderator:
Yes I believe you should put that piece of code in the draw event. float_spd is a variable but it is an angle, and I’m not sure about gm2 but in gm1.4 sin functions register angles in radians. So you might have to use float_spd = degtorad(360) can be any angle but I used 360 as an example. float_dis I believe is also a variable and should be in pixels

You might want to define them in the create event, but it might not require it! I’m new to gm2 haha came from gm1.4.
......wat
 
Z

Zachary_tzy

Guest
......wat
Was something I mentioned wrong? Please correct me if i'm wrong thank you! From what I know, gamemaker's trig functions work in radians? Sorry if i'm mistaken on that. Also was just confirming with his question on where to place the pieces of code, sorry if I intruded on your answer!
 
Well, the functions do indeed work in radians, but my code doesn't require the changes you are proposing. It's just a simple sine wave. float_spd is merely how fast the wave will go.
 
Z

Zachary_tzy

Guest
Well, the functions do indeed work in radians, but my code doesn't require the changes you are proposing. It's just a simple sine wave. float_spd is merely how fast the wave will go.
Edit: reading the code again, I was mistaken, and my advice is invalid! Sorry for the mistake!
 
Top