• 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!

GameMaker Creature with many legs walking over platforms

S

steveyg90

Guest
Hello all,


I'm working on trying to get a large creature object climb up and down tiles, hard to explain so drew a quick picture:

https://pasteboard.co/I9GLlEE.png


Does this make sense? I was thinking of having the legs as separate sprites and the body of the creature the parent to these legs.
 
T

ThePropagation

Guest
Are the legs separated literally like in the image or just representation?
 
S

steveyg90

Guest
The legs would be separate. I can only think of the way I show it is how to do by having separate sprites and detect the collision on them. Overwhelm game does something similar looking at some of the bosses in there.
Although that was coded in Haxe and OpenFL.
 
T

ThePropagation

Guest
So what I mean is like rayman with invisible limbs or not?
 
T

ThePropagation

Guest
ok so the body object needs an offset Y variable to tell the body how far off the ground to be. then for the feet you can have the x value move with the body x and have the feet jump and have a collision event where the y doesn't go lower then the blocks it's walking on.
 
S

steveyg90

Guest
ok so the body object needs an offset Y variable to tell the body how far off the ground to be. then for the feet you can have the x value move with the body x and have the feet jump and have a collision event where the y doesn't go lower then the blocks it's walking on.
Yeah, this is what I thought, so going with separate objects for the feet is the way to do this?
 
D

Danei

Guest
Separate objects is probably the easiest to conceptualize and prototype, but you could also do this with a single object if you wanted to track an array of foot positions or something.

To me the most difficult part seems to be handling the hitbox of the creature if it needs one.
 
S

steveyg90

Guest
Separate objects is probably the easiest to conceptualize and prototype, but you could also do this with a single object if you wanted to track an array of foot positions or something.
Will possibly be single object (main body) which will have an array of objects for the feet :)
 
T

ThePropagation

Guest
I made an Ant Queen with 23 parts. Looking back all of the parts should have been children of the controller object. I made an X Y and angle variable for each joint in the controller object. For example,

Code:
antBodyX = objQueenControl.x
antBodyY = objQueenControl.y
antBodyAngle = objQueenControl.image_angle

antArmX = antBodyX + lengthdir_x(dist, dir)
antArmY = antBodyY + lengthdir_x(dist, dir);
antArmAngle = antBodyAngle + (whatever you want)
and so on for the other parts. I basically created an FK skeleton for separate overlapping sprites, and I gotta say, it looks really beautiful. At 60 fps and eased movements, it looks great
 
S

steveyg90

Guest
I made an Ant Queen with 23 parts. Looking back all of the parts should have been children of the controller object. I made an X Y and angle variable for each joint in the controller object. For example,

Code:
antBodyX = objQueenControl.x
antBodyY = objQueenControl.y
antBodyAngle = objQueenControl.image_angle

antArmX = antBodyX + lengthdir_x(dist, dir)
antArmY = antBodyY + lengthdir_x(dist, dir);
antArmAngle = antBodyAngle + (whatever you want)
and so on for the other parts. I basically created an FK skeleton for separate overlapping sprites, and I gotta say, it looks really beautiful. At 60 fps and eased movements, it looks great
That looks like the way to do it. Do you have a video of it ;-) ?
 
T

ThePropagation

Guest
I don't have a video, but we can talk about the joints, I need to get the code together hold on, I'm going to edit this comment with it

EDIT:

Ok, what I did was have everything separate, and in the control object have an x, y, angle, and destination variable for each joint.

VARIABLE SETUP

So to begin with I made 2 variables to dictate how far off the ground your creature is: groundY and offsetY. groundY should be where the ground is and you can edit that any time when the ground raises or lowers. offsetY is how far you want the creature off the ground, also, changable any time if the beast is crouching you can decrease the offsetY. in the step event of the controller i used this code

Code:
y += ((groundY + offsetY) - y) / 10;
to smoothly transition to the Y you want the creature to be.

I think the reason I didn't parent is because I already set up the dependencies in the variables. For example I did (head = center + distance) and (mouth = head + distance) and (shoulder = center + distance) and (elbow = shoulder + distance) etc. How I do that was in the previous comment of mine.

Now, for smooth transitions I made an additional variable for each joint called headDest, mouthDest, for the destination of where you want these angles to go. How I do this is for every joint in the step event, do this

Code:
headAngle += (headDest - headAngle) / 10;
Now after you set up these variables you're ready for manipulation of them.

I set up a system of poses. In the step event I did

Code:
if pose = 0
{
       headDest = (angle you want)
      shoulderDest = (angle you want)
     elbowDest = (angle you want)

      offsetY = (how far off the ground you want)
}
you can instantly pose the creature how you want.

Now, finally you do your state machines how you wish, so, have another variable called timer and every state change, timer = 0 and in every state timer = 1

Code:
if state = queen.jump
{
       timer += 1

      if timer = 1
       {
                pose = 4
               x += 25
       }

       if timer = 40
       {
                 pose = 6
                  state = queen.wait
        }
}
As far as I know that's all, if you have any other questions let me know
 
Last edited by a moderator:
T

ThePropagation

Guest
I forgot about this. For each part (again, not children, there's gotta be an easier way but I don't know how to structure it) put this in the step event

Code:
x = objQueen.backLeftKneeX;
y = objQueen.backLeftKneeY;

image_angle = objQueen.backLeftKneeAngle;

image_xscale = objQueen.image_xscale;
image_alpha = objQueen.image_alpha;
 

RujiK

Member
@steveyg90 I'm not @ThePropagation obviously, but I have a brief semi-tutorial on procedural animations which should be enough to get you started:

https://twitter.com/TheRujiK/status/969581641680195585

It's a bit more advanced that the code that @ThePropagation posted, but his idea is the basis of how it works.

Without any bells and whistles it looks like this:

WITH bells and whistles it looks like this:

Obviously my approach is top down, but adding collisions to the feet would not be that difficult. You would just need to have areas which are declared "Step friendly."
 
S

steveyg90

Guest
@steveyg90 I'm not @ThePropagation obviously, but I have a brief semi-tutorial on procedural animations which should be enough to get you started:

https://twitter.com/TheRujiK/status/969581641680195585

It's a bit more advanced that the code that @ThePropagation posted, but his idea is the basis of how it works.

Without any bells and whistles it looks like this:

WITH bells and whistles it looks like this:

Obviously my approach is top down, but adding collisions to the feet would not be that difficult. You would just need to have areas which are declared "Step friendly."
Wow, that is awesome and thanks for sharing, will definitely take a look at how you have done it.
 
T

ThePropagation

Guest
Holy cow @RujiK that looks great! wow, this looks like an IK rig, I used FK which works also. Does that link show how it's done? looks like a spline
 
S

steveyg90

Guest
I don't have a video, but we can talk about the joints, I need to get the code together hold on, I'm going to edit this comment with it

EDIT:

Ok, what I did was have everything separate, and in the control object have an x, y, angle, and destination variable for each joint.

VARIABLE SETUP

So to begin with I made 2 variables to dictate how far off the ground your creature is: groundY and offsetY. groundY should be where the ground is and you can edit that any time when the ground raises or lowers. offsetY is how far you want the creature off the ground, also, changable any time if the beast is crouching you can decrease the offsetY. in the step event of the controller i used this code

Code:
y += ((groundY + offsetY) - y) / 10;
to smoothly transition to the Y you want the creature to be.

I think the reason I didn't parent is because I already set up the dependencies in the variables. For example I did (head = center + distance) and (mouth = head + distance) and (shoulder = center + distance) and (elbow = shoulder + distance) etc. How I do that was in the previous comment of mine.

Now, for smooth transitions I made an additional variable for each joint called headDest, mouthDest, for the destination of where you want these angles to go. How I do this is for every joint in the step event, do this

Code:
headAngle += (headDest - headAngle) / 10;
Now after you set up these variables you're ready for manipulation of them.

I set up a system of poses. In the step event I did

Code:
if pose = 0
{
       headDest = (angle you want)
      shoulderDest = (angle you want)
     elbowDest = (angle you want)

      offsetY = (how far off the ground you want)
}
you can instantly pose the creature how you want.

Now, finally you do your state machines how you wish, so, have another variable called timer and every state change, timer = 0 and in every state timer = 1

Code:
if state = queen.jump
{
       timer += 1

      if timer = 1
       {
                pose = 4
               x += 25
       }

       if timer = 40
       {
                 pose = 6
                  state = queen.wait
        }
}
As far as I know that's all, if you have any other questions let me know
Many, many thanks for taking time to show this! Kudos!
 
Top