Skip to main content
gamedev.net
🔒 Locked

simple 2D problem

Started by MSW 2 replies 1.1k views
Original Post
MSW
MSW
At least I assume this is simple, as many games feature this sort of thing... I am a absolute noobie when it comes to physics, and I''m looking to implament a chain in my 2D game...when the player moves around the 2D sideview enviroment, the start point of the chain moves with them, and the rest of the chain should follow along. the chain links are just simple sprites that should always be a set distance from one another, the only collisions with these links are with enemies(done with sphere to sphere collision checks)...as the game is playied the chain can grow dynamicly (additional links added to the end at any point in the chain motion). over time, without the player moveing, the chain should come to a rest hanging below the player (friction that causes this?) Now I assume that each link is actualy a bit like a pendulum, with the pivot point being the previous wieght in the chain linked list structure...problem is that I don''t understand the maths involved, I''ve done some web searches but the resaults are all greek to me...can anyone help with clear code style links\explanations?
oliii
oliii
I achieve a good result using the verlet integration stuff, with stiff constraints. It works very well.

Advanced Character Physics (Thomas Jakobsen)


Once you've read the article, All you have to do is assign an infinite mass to the chain link at the player (and move it along with the player), and link your particles with stiff segments; as explained in the docs. They'll react like a tail or a whip. You can implement this in a matter of days, it's that simple.

BTW : for your problem, chapter 5 and beyond are not necessary. Cloth simulation is just an extended case for a chain (It's like a 2D chain), so you can stop there.

[edited by - oliii on December 28, 2003 4:53:09 PM]
Everything is better with Metal.
oliii
oliii
another way is to cache old player positions, like a trail of points behind the player, and link all those points with segments. Starting from the current player position, you place the first link, then walk along the segments, until you reach the distance required to the next link, place the link there, then carry on along the segments, place the next link, ect...






Old player positions : A0 -> A5
--------------------------------



A0 A1 A2
+-------+--+
|
+ A3
\
\ player
\ A4 O
+--------+- A5
/ \






Links : L0 -> L7
-----------------




L7 L6 L5
''''O''''''O''''''O''
''
O L4
''
O L3
'' L0
''O''''''O''''''O
L2 L1


With this method, it''s gonna be like in Saint Dragon (old shoot''em up), where the gragon had a tail that he could use to protect himself. The tail was not affected by gravity, or any other forces, it merely followed the dragon''s movements.

With the previous method, the tail can react to impulses and other effects, but it requires collison detection with the environment and other things.
Everything is better with Metal.
MSW
MSW
Thanks for the info, that artical should be of great help.

the system I have right now is much like the one oliii describes, except it stores angles for each segment...with each segment trying to match it''s angle to the previous one in the chain...this works well and is controlable, but it lacks the sense of inertia needed...my game is sort of a vertical version of Saint Dragon...

Again thanks for the help :D

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.