GM Tips: Game Maker Inventories
Note: this was created by a former student. Hopefully it is detailed enough for you.
... for picking up a new weapon
... for picking up a key, money, etc.
Step 1: Create a variable
- in the Create event of the GoodGuyObj, set the value of a new variable called WeaponVar (or whatever you want) to be zero. This can be found under the Control tab. Later, you will se the value to one which means you own this thing.
Step 2: Create two objects using the same sprite: a Pickup Object and the Real Thing
- Create a WeaponPickupObj.
- Go to your GoodGuyObj and add a collision event with the WeaponPickupObj. Add two actions
- Set the WeaponVar to 1
- Destroy the instance of the WeaponPickupObj.
- Create the WeaponRealObj and give it whatever settings you need for your game... such as those for a bullet.
Step 3: Use the If control to use it.
- This step depends on your own game. For example, you can use the If Variable action (found on the control tab) to say if WeaponVar = 1 then shoot WeaponRealObj. Otherwise, shoot the regular bullet.