Aliens Style Motion Tracker for Godot 4
An Aliens style motion tracker where the position of the blips are only updated each ping. It uses a shader and a script that can be applied to a ColorRect or TextureRect and will blend with their contents.
Try the test scene above. Move with the WASD/Arrow keys and rotate with Q and E.
It is distributed under the MIT Licence meaning you can freely use it in your own projects as long as credit is given.
How to use
Download the MotionTrackerAsset.zip file and expand it. This is a full copy of the test scene that you can look at to get an idea of how the motion tracker can be used.
In your own project create a ColorRect or TextureRect to be the tracker. For a circular or square tracker its Size should be in the ratio 1:1 and for a semicircular or rectangular tracker its Size should be in the ratio 2:1.
Attach the motion_tracker.gb script to the ColorRect or TextureRect. If you are using a TextureRect uncomment line 5 in the script and comment out line 6. If you are making a semicircular or rectangular tracker add the code in line 85 of the script to the end of whichever if statement you use in line 86.
Apply the motion_tracker.gdshader to the ColorRect or TextureRect. If you are making a semicircular or rectangular tracker uncomment line 29 in the shader and comment out line 30.
In the script and shader change the MAX_BLIPS constant to the maximum number of blips you want displayed in the tracker. If there are more enemies in range of the tracker than MAX_BLIPS then only the MAX_BLIPS number of enemies closest to the centre of the tracker will be displayed. Setting MAX_BLIPS too high may impact performance.
Set the SCALE constant in the script to set the range of the tracker, i.e. how many pixels in global space the tracker's radius covers.
You can adjust the speed of the pulse by altering the MAX_PULSE and PULSE_SPEED constants in the script.
See the comments in the script and shader and the shader's parameters for more ways to customise the look of the tracker.
Your player object will need to call the function setup_player(self). This will make their position and rotation control the central position and rotation of the tracker. The tracker will not update until a player has been setup.
Your enemy objects will need to call the function add_enemy(self) . You can remove an enemy from the tracker by calling remove_enemy(self). If they have a blip shown on the tracker it will not be removed until the next ping. You do not need to remove an enemy from the tracker when it is going to be deleted as the script will automatically delete handles to enemies that are nolonger valid.
Updates
10 March 2024 v1.1
- Added an alternative line of code to the script to fix an issue where blips might not be displayed if the corners of the tracker were being rendered and the blips were rotated.
- Added alternative lines of code to the shader and script to cover making semicircular and rectangular trackers.
Status | Released |
Category | Assets |
Release date | Mar 09, 2024 |
Author | Steampunkdemon |
Made with | Godot |
Tags | Aliens, Godot, motion-tracker, Shaders |
Code license | MIT License |
Leave a comment
Log in with itch.io to leave a comment.