Last active
March 7, 2019 16:15
-
-
Save ACatThatPrograms/05b76ba6de12a2ef4bd9424eb48d4347 to your computer and use it in GitHub Desktop.
Written in GDScript :: First function tracks movement direction as a vector and entity facing direction of follower entities that trail behind the player for classic JRPG like caching of last-player-positions within an array for utilizing within the follower entities for movement : The second function is using this array and providing a unique e…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func check_trail_cache(): | |
if player_last_pos != player.position: | |
position = player_trail[0][0] | |
move_dir = player_trail[0][1] | |
if position_index < frame_offset: | |
position_index += 1 | |
else: | |
position_index = 0 | |
if player_trail.size() > frame_offset: | |
player_trail.pop_front() | |
player_trail.push_back([player.position, player.move_dir]) | |
last_pos = position | |
else: | |
move_dir = Vector2(0,0) | |
player_last_pos = player.position |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func follower_check_trail(): | |
if player_last_pos != get_tree().get_nodes_in_group("party")[0].leader.position: | |
position = player_trail[0+position_offset][0] | |
move_dir = player_trail[0+position_offset][1] | |
player_trail.push_front([get_tree().get_nodes_in_group("party")[0].leader.position, get_tree().get_nodes_in_group("party")[0].leader.move_dir]) | |
else: | |
move_dir = Vector2(0,0) | |
player_last_pos = get_tree().get_nodes_in_group("party")[0].leader.position |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment