• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Platformer gravity + enemies?

V

Vincent

Guest
Hello there! So I'm working in a platformer, and I'm using GML, and I want to use a code for the player movement and gravity as well for the enemy gravity. The thing is that all the code I've tried only works for the player, because it uses in the same code the variables of movement and the gravity, which means that I can't separate the "gravity" part and use it in the enemy.
What code should I use?
Thanks a lot!
 

hogwater

Member
If I understand the question, you just need to give enemies their own variables analogous to the ones that your player object has. You can also make any variables that you want many objects to share global.

It sounds like you found some player movement code, but you don't understand why or how it works. If you learn how it works you'll be able to give your enemies what they need to interact with the environment as well.
 
V

Vincent

Guest
If I understand the question, you just need to give enemies their own variables analogous to the ones that your player object has. You can also make any variables that you want many objects to share global.

It sounds like you found some player movement code, but you don't understand why or how it works. If you learn how it works you'll be able to give your enemies what they need to interact with the environment as well.
Thanks! I'll spend some time researching it :D
 

TheouAegis

Member
gravity is a built-in variable that can be set for each instance. If you made some variable like global.grav, then that's your own fault for making it a global variable (although gravity should be the same for all instances, technically speaking...).
 
Top