
This is where to imagine your player is stationed in the room when the collision check is made. The first and second arguments to the function are usually set to x and y respectively. The first and second arguments are the x and y coordinates where the collision will be checked, and the third argument is the object with which we’re checking a collision. It is better to use this function in a condition than using a collision event, since this way you have more control over how your collisions work. The function place_meeting() can be used for checking a collision with another object. Suggested by Karolis Poviliūnas and John Benson

Through the same menu, you can also change the scaling and rotation of the instance, and set a unique ID so that you can access that particular instance through code. This way, you can assign different HPs to different instances, inside their creation code.
#Gamemaker whenever object runs script it deletes code
When you place instances inside a room using the Room Editor, you can right click on them and open the “Creation Code” window (or in GMS2, double-click) and type code in it. As a beginner, your first instinct might be to create another object and change the HP inside it. Say you want to have two enemies, one with 4 HP and the other with 10. #3: Different values for different instances So before copying code over to your project, make sure you at least try to understand how it works. Even if you do use code from a tutorial, do not attempt to modify it or expand upon it unless you understand how it works. If you’re serious about something, code it yourself. Tutorials exist as a guide so that you can understand how things work. You might think that it’d be a good idea to use a tutorial to build a game/system, but it’s not.

In a project, you can’t have complete control over your workings if you don’t understand how any part of your code works.

While that appears to be fine, it’s only going to increase the trouble. Sometimes you just want to make something work, so you copy over some code from a tutorial, even if you don’t understand how it works. #2: Don’t copy-paste code without understanding Here are some tips which should help beginners do some things right and know what they might be doing wrong.īefore Googling something or asking someone about an issue, make sure to check the relevant entry in the documentation – it may contain information that might help you solve your problem.
