Object Walking (Advanced?)

C

Cloud Wolf

Guest
Hey I have been trying to sort this problem out for about 8-10 hours and haven't been able to find anything online to help me nor have I been able to figure it out. The goal is to create a system which uses objects for the player, which are then moved, rather than using sprite animations. I want to do this because it should look more fluid and realistic than simply using sprites and it should be a lot more customization in terms of arm positioning (for possible weapons) and adding new animations. I am not sure if it is possible within game maker studio but I have seen games utilizing a system like this (evident from the design of the game) and would love to incorporate it myself. If you know how to do this, or can find out, thank you and I look forward to seeing a response, if any.

PS: The image used was an attempted design at creating just the right arm. The game would be a 2d platformer with the character facing almost profile. If you can just help me find out how to make the arm that should be good enough.
 

Attachments

C

Cloud Wolf

Guest
What I'm looking for is a bit different than "just moving sprites" I want a better system to do so in which I can (for instance) have a gun object and inside the object tell the arms to be located at the front area and at the handle. (simply doing obj_hand1.x,obj_hand1.y...etc) From this it will position the rest of the arm pieces and such correctly. Also when the player walks it animated correctly. Essentially it would involved a bunch of dependent and independent objects
 

nesrocks

Member
You want objects positions and orientation being parented by other objects, like in flash? I figure that could be programmed, so, technically, GMS supports it. But I see your point, in some games it would be a lot easier if this was built in. You could program a base object that does this, and use that as a parent for all objects that require this behavior.
 
What I'm looking for is a bit different than "just moving sprites" I want a better system to do so in which I can (for instance) have a gun object and inside the object tell the arms to be located at the front area and at the handle. (simply doing obj_hand1.x,obj_hand1.y...etc) From this it will position the rest of the arm pieces and such correctly. Also when the player walks it animated correctly. Essentially it would involved a bunch of dependent and independent objects
Right, and it's still exactly what I pointed out, just moving sprites. Did you read the rest of my post or just get caught at what I said in the beginning?
 

nesrocks

Member
I think what he's talking about is not inverse kinematics, it's just linked objects. IK is just a controller for the end point of the chain, but he wants the chain itself.
 
Last edited:
I think what he's talking about is not inverse kinematics, it's just linked objects. IK is just a controller for the end point of the chain, but he wants the chain itself.
Right, but my point is that it is easily possible for GM to do this and there is native support for it, should you choose to use something that already handles this. If you know where the gun is, place the hand there and the arm will follow suit. Vice versa, if you know the hand ends up at the end of the arm chain, place the gun there. I know what he wants, but he hasn't asked a direct question as to what his issue actually is, so I could only offer a basic answer.
 

Nux

GameMaker Staff
GameMaker Dev.
If this is the effect you mean, I would recommend saving up some money for spine, because coding it from scratch (like I did) is a pain if you don't know what you're doing.

EDIT: alternatively, if you want to learn how to do it yourself, I found this tutorial has a pretty good explanation.
 
C

Cloud Wolf

Guest
Thanks, Nux, that is kind of what I am looking for. What I meant was that I have been trying for a long time to make the program to do something of that sort and was wondering if there was a good way to approach it. I tried to use geometry to find the correct angles and such but the way game maker uses origins and such made it strange and it was not working.

And physics is very bad to use because then ur game is dependent on the physics engine which could be a bad thing

If this is the effect you mean, I would recommend saving up some money for spine, because coding it from scratch (like I did) is a pain if you don't know what you're doing.

EDIT: alternatively, if you want to learn how to do it yourself, I found this tutorial has a pretty good explanation.
Also, thanks for the video its very good, better approach than geometry
 
M

MishMash

Guest
Thanks, Nux, that is kind of what I am looking for. What I meant was that I have been trying for a long time to make the program to do something of that sort and was wondering if there was a good way to approach it. I tried to use geometry to find the correct angles and such but the way game maker uses origins and such made it strange and it was not working.

And physics is very bad to use because then ur game is dependent on the physics engine which could be a bad thing
How game maker presents the objects is completely irrelevant to the problem you are trying to solve. The question in this case isn't really about whether "GM" can do it, but rather a question of how you achieve this in GM. Using the options available for spine are just objectively easier because it means you do not have to program any of the inverse kinematics physics yourself.

The maths is going to be difficult, and it is going to equally involve an understanding of how you would structure such a system in code. The best thing you can do is disconnect yourself from any assumptions you are making about GM and think about the problem purely in terms of mathematics. You have a set of coordinates for each separate body part which you want to manage. You will likely have one body part you are trying to modify and after each modifcation, you would want to apply the inverse kinematic equations to dynamically re-calculate the position of all other body parts, subject to a series of user specified constraints (such as maximum angle of rotation, some form of mass quantifier to control how much movement of one component affects another (i.e if you pull on a bent arm, the arms are very loose and the elbow will straighten out before the torso then gets rotated forward).

In programming terms, it is very common to separate the calculations of what you are trying to achieve from what you are drawing. In this case, objects may not be the best solution unless you are very aware of how all of these interactions play together, and what variables exist to link separate parts together (if anything, objects might be the solution you decide to implement after getting something to initially work, but that's more a result of organisation, rather than the problem itself).

So to start, what you will want is to have a series of coordinates representing the joints between each body part. Body parts would then be drawn based on the positions of these joints. For example, the upper arm position and rotation would be determined by finding the centre and angle between the shoulder and elbow joint, you could then draw a sprite at that central position (allowing for any offset in the origin you have placed to ensure it aligns correctly, though this should really be centered), and you could equally apply the rotation. Similarly, you would repeat the same process for the lower arm except between the elbow and wrist. You could then place the hand purely at the position of the wrist, but offset the origin of the sprite such that it is centered at the base of the hand, rather than in the middle (you can logically think about where you would position the hand relative to the wrist).

Back to the calculations, a "simple" structure for how you would organise such a system would involve you attempting to move one of the coordinates, you would then use equations to move the coordinate as far as it could in the desired direction, whilst equally updating the other coordinates at the same time. Unfortunately, this isn't easy, so i'd stick with what BattleRifle said and just try and do it through spine, because this will be managed for you.

Also, how "dependent" you are on a system that you are using, whether it be physics, or some extension you may be using is entirely at your discretion. You can mix and match systems as much as you like, you just need to be aware of which situations you are using one in, and which ones you are using another in. You can also override the settings of any such system, rather than purely relying everything to be done for you. What I'm getting at is that using GMs physics system does not deny your ability to utilise your own collision code at the same time. For example, if you had an object or grid or something that did not conform to how physics worked, you could equally perform your own collision checks and simply use the physics system for resultant motion once your own collision checks have verified a location is free.

Going forward, try not to think of problems in terms of whether "GM can solve them", but instead reason about what you logically need to achieve, break them down into a series of steps and attempt to create each step one at a time. "GameMaker" will be able to do almost anything you can think of. It's limitation is your ability to actually achieve what you are trying to achieve. Granted, this means some things will be hard, however every hard problem is equally a learning opportunity and often times it is better to try and attempt a problem, and ask questions about the problem itself, rather than the software, given that this is quite clearly a mathematical/programming related issue, not an issue with the software itself.
 
C

Cloud Wolf

Guest
How game maker presents the objects is completely irrelevant to the problem....
I totally get what you meant, I have been working at the problem outside of game maker for a while, I was more asking for a way to solve it(which was answered with Inverse Kinematics (I know how to do it)) and I just asked if game maker had any specific things to help with it, since they have so many good functions I don't know about yet. Anyways I think I'll try working out the inverse kinematics a bit but I will probably just buy Spine because it will most likely be more smooth. My plan would be to just make a game with the asumption I will have fluid looking bodies and if I can complete it I can add in the fluid animation movements with Spine afterwards. Thanks for all the suggestions though.
 
Top