Tethering item system

T

TheCount15

Guest
Hi I am relatively new to GMS2 and game programming. I am looking for ideas on how to implement a specific type of inventory/item system. In my game I have the player control a space ship and collect items in space. I want to make a system where the inventory of the ship is based on the items being tethered to the player. For example: player destroys asteroid, which causes an ore to spawn. The player then collides with the ore and the ore is then tethered to the player (sorta like Star Trek Tractor Beams pull items towards ships). The player will only be able to tether a set amount of objects but they will follow the player until needed. I am trying to come up with ideas on how to make the ore follow the player and how to make only a specific amount of ore be able to follow. Let's say the player can drop a following ore by pressing 'Q'. Would love to find examples/ideas if anyone has any.
 

Xer0botXer0

Senpai
Electromagnetic pulses.. which attracts surrounding ore.. fires periodically .. caution: ore may be flung past ship..
 

Yal

šŸ§ *penguin noises*
GMC Elder
Hi I am relatively new to GMS2 and game programming. I am looking for ideas on how to implement a specific type of inventory/item system. In my game I have the player control a space ship and collect items in space. I want to make a system where the inventory of the ship is based on the items being tethered to the player. For example: player destroys asteroid, which causes an ore to spawn. The player then collides with the ore and the ore is then tethered to the player (sorta like Star Trek Tractor Beams pull items towards ships). The player will only be able to tether a set amount of objects but they will follow the player until needed. I am trying to come up with ideas on how to make the ore follow the player and how to make only a specific amount of ore be able to follow. Let's say the player can drop a following ore by pressing 'Q'. Would love to find examples/ideas if anyone has any.
For simple cases, you could just have an array of the last 200 x/y positions the player has been to (which are only updated when they're moving). Items are stored in a standard inventory, but drawn at these previous positions: the first item at the 10th previous position, the second item at the 20th position and so on. Now the items will trail behind the player flawlessly, but without any real physics involved. (You could still have them be physical objects instead of pure inventory data blobs - nothing's stopping you from putting instance IDs in an array. I think having an actual inventory is going to be helpful for things like crafting menus, but if you plan to have physical crafting stations you sling items into, it might not be necessary)

To make items follow the player more smoothly, make them interpolate towards the target position instead of jumping there instantly: x = lerp(x,obj_player.prev_x[(my_inventory_slot+1)*10],0.1)
 
T

TheCount15

Guest
Thank you all so much for the ideas. I have not made it far enough to start implementing the custom inventory system yet. But I wanted to get a few different ways to approach that hurdle when I come to it. Thanks again.
 
Top