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

GML 2 Linked objects linked by a Chain

E

Edan Momu

Guest
I'm working on a top-down game and I want to create a mechanic where the player is chained to a metal ball the metal ball can move but it slows down the player. And I'm having a problem with getting it to work properly.

I need the player to be able to move, if it's further than the length of the chain, pulls objects into range of the chain, and then check for the collisions of both the player and the ball against a wall object.

Getting the player to drag the ball is no problem, getting the collisions to work is no problem, I have a problem getting both systems to play nice with each other, I've tried a few ways to do it but always get jitter or some other problems with collision.

I'm asking for ideas on how to handle something like this, none of the code I have right now is working properly.
 

obscene

Member
Just thinking about it (having never tried it) I would think it's possible to do it without the ball checking for collisions. The ball would follow the player if the chain was extended. It's not as realistic, so don't know if it fits your style, but if the ball followed the player exactly it would never hit a wall. In order for it to work, you would need to store an array of the player's previous positions and if the chain is extended the ball lerps itself to some position on the array that gets it back within range.

Just a thought.
 
E

Edan Momu

Guest
Just thinking about it (having never tried it) I would think it's possible to do it without the ball checking for collisions. The ball would follow the player if the chain was extended. It's not as realistic, so don't know if it fits your style, but if the ball followed the player exactly it would never hit a wall. In order for it to work, you would need to store an array of the player's previous positions and if the chain is extended the ball lerps itself to some position on the array that gets it back within range.

Just a thought.
This could work, but I want the chain to be a line with no collision so it's easier and also I want the ball to be able to drag the player if something were to push the ball.
 
Last edited by a moderator:

NightFrost

Member
Isn't the chain itself also a problem, where it needs to be able to wrap around obstacles, pull its slack and, ultimately, the item attached to either end? The problem sounds like inverse kinematics. I have only given that a quick glance, but it seemed like quite a bit of math, and you'll find a lot of talk about robot arms because their movements are a case of inverse kinematics.
 
E

Edan Momu

Guest
I was thinking to have no chain collisions or physics, so the chain is always a straight line, similar to Spelunky.
 
Top