I cannot be held liable for any claim, damages, or other liabilities that may arise from, out of, or in connection with the product or the use or other dealings in the product.
#Game maker studio 2 collision code
#Game maker studio 2 collision how to
Head to my Patreon page to learn how to get your copy. If you're supporting me on Patreon for the $5 tier or higher you will get this library for free. To learn more about how to use this library, check out the API Reference. Input_action_add(0, key.jump, ord("Z"), gp_face1) Input_action_add(0, key.down, vk_down, gp_stickld) Input_action_add(0, key.up, vk_up, gp_sticklu) Input_action_add(0, key.right, vk_right, gp_sticklr) Input_action_add(0, key.left, vk_left, gp_stickll) Mapping analog sticks as digital inputs.Detecting the hold time and the last pressed action.Support for keyboard, controller, and mouse input.This library is made by Mors ( Website | Patreon). Since I made this library primarily for my own personal projects, I will keep updating it on a regular basis. It also comes with an example project that will show you the basics. This library is only tested on the Windows, HTML5, and GXC targets, but it should work on other platforms as well. It also includes a bunch of other helpful extra features, like detecting double and long presses, and input recording/playback. The above code will check for a collision with instances of "obj_Enemy" and if there is one, it will reduce the "hp" variable by the amount stored in the colliding instance's "dmg" variable and then destroy the colliding instance.WInput is a simple but also powerful input management library for GameMaker Studio 2.3 that allows you to create actions and assign them different inputs with ease. Var _inst = instance_place(x, y, obj_Enemy) Real (either an instance ID value or the keyword noone) Instance_place_list(floor(x), floor(y), obj_Enemy, list, true). Note that the given x/y coordinates will be rounded to the nearest integer before the check is performed, so if this is not what you require (or you have been using a legacy GameMaker product), you should floor the coordinates in the check: This function also accepts the special keywords all and other and will return the keyword noone if no collision occurs, or the unique instance ID value of the instance found if a collision does occur. this function will return the unique instance id of the object being collided, but if that is not needed it is slightly faster to use the function place_meeting(). This will work for precise collisions, but only if both the instance and the object being checked for have precise collision masks selected otherwise only bounding box collisions are applied. When you use this you are effectively asking GameMaker Studio 2 to move the instance to the new position, check for a collision, move back and tell you if a collision was found or not. With this function you can check a position for a collision with another instance or all instances of an object using the collision mask of the instance that runs the code for the check.