• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Moldorm Body Segment Direction *SOLVED*

Odolwa

Member
I've been looking at some code which recreates the Moldorm boss from Link to the Past, i.e. a segmented worm where the individual parts all follow the head section as it moves after Link. I created a sprite of my own, but the segments behind the head are more rectangular in shape than the circular sections of Moldorm. As such, I wanted to try and keep the segments more in line with each other but I have run into a slight problem.

Specifically, the sections behind the head all follow the section that preceded it, but the segmentation comes from the fact that before a given part will turn there is a slight delay. Because the head is not bound by this delay its image angle is set to 'direction', however, if I apply the same line to the body parts, the alarm delay results in a jerky animation as they turn to line up with each other. The only solution I could come up with so far was to have the sections match the head's image angle, but this results in all the pieces turning far too early and in unison. Can anyone suggest a way to deal with this? Thanks.

Here's the code in the Create, Alarm and Step events of the body part, respectively:
Code:
creator = -1; //Body segment ID no., set in the head object!!
delay = 0.13; //Alarm delay to space out the segments w/ how quickly they update their coord's!!
alarm[0] = 1; //Init. Alarm to get the segments turning in the dir. of the segment that preceeded it!!
Code:
dir = point_direction(x,y, (creator - 1).x, (creator - 1).y); //Each segment in the body follows the dir. of the 1 that preceeded it where 'creator' is the 'id' no. assigned to a given segment!!
direction = dir; //Commit to dir. change!!
alarm[0] = room_speed * delay; //Delay the alarm so as to prevent the segments from piling up or being too far apart!!
Code:
image_angle = direction;
 
D

Danei

Guest
you could try lerping the image_angle between its current value and direction, which should make them slowly turn, fine-tuning how it looks by fiddling with the magnitude of the lerp.
 

Odolwa

Member
Apologies for the long delay in responding, I was testing the code and there were other interruptions. In any case, thank you for the link Samspade, I managed to get the code on that other thread working. The only change I really needed to make was to add the line:
Code:
image_angle = point_direction((creator-1).x, (creator-1).y, x, y)
in order to get the individual segments to turn more naturally.
 
Top