This project contains a series of scripts designed to generate an ordered list of all targets with a given parent object. This list can then be scrolled through to select any of the given targets and "lock on" to them. If a target leaves the given range or is destroyed, the scripts will update the list again and target the next nearest, or it will select the next one on the list and find another target to add (this behaviour can be changed).
Live Demo Here! http://bit.ly/targetingsystemlive (Use the mouse wheel to change targets)
All scripts are called from a single object and can be easily added to a player or an enemy object later. The PARENT object must be used for all objects that you wish to target and should not be changed.
The included demo project contains two folders of objects in the resource tree. The BASE objects are the ones you should be using in a real game, and the DEMO objects can be removed. Note that the demo objects hold a lot of information in the form of comments so take a moment to read through them before removing them from the file.
Included with this project is a script from GMLScripts, which you can find here: http://www.gmlscripts.com/script/instance_nth_nearest
GMLScrpts licence can be found here: http://www.gmlscripts.com/license.txt
Update fixes a minor bug where the BASE object uses a global variable that was misnamed. The update also adds a new script "scr_TARGET_Pick" which permits you to manually select an instance and target it (adding it into the target list if required).
Version 1.0.2. Published November 20, 2016
Created with GameMaker: Studio v1.4.1763
This asset hasn't received enough reviews yet.
You can only review assets you've bought.
The original version of this targeting system wasn't actually what I needed for my game. I intended to modify it for my uses but was experiencing a lot of trouble. I contacted Nocturne and explained the bugs I'd found with the code as well as my goal, and within 10 hours, probably less because I was sleeping, he had fully implemented the feature I was looking to add and it works extremely well. So now I have all their awesome features and the one I needed, which was point and select to target. I definitely recommend you use this, even if you're not going to implement it into your game, the way the code is structured has taught me a lot as I am a novice coder. A+ rating from me.
Just remember, you need to put the code from the Base object's "Create" & "Draw" events in your player object to ensure that it works. Also set the Base as the parent. Those were two issues I was having that they explained well in our correspondence.
Total size 46.1 KB