Sonic the hedgehog physics o_<

  • Thread starter Thread starter myutwo33
  • Start date Start date
  • Tags Tags
    Physics
AI Thread Summary
The discussion centers on developing a Sonic the Hedgehog-style 2D platform game, specifically addressing the physics of a character running up a curved surface. The main challenge is calculating the character's position and speed on the curve based on initial parameters like previous position, speed, and the curve's radius. Suggestions include modeling the character's movement as frictionless and using energy conservation principles to determine velocity. Additionally, the importance of calculating the normal force is emphasized for understanding when the character will fall off the loop. The conversation highlights the balance between accurate physics and enjoyable gameplay, suggesting that gameplay should take precedence over strict adherence to physics.
myutwo33
Messages
2
Reaction score
0
hi guys. I am attempting to make a sonic the hedgehog style 2d platform game, in planning all this out I'm having to go though a lot of physics problems. I think I have all of them ironed out apart from the one I'm going to tell you.
when the game character runs up a curved surface (shaped like he was running up the inside of a circle), I need to be able to work out at what point of the curve will he be on, and traveling at what speed after a certain amount of time has passed. given parameters such as his previous position on the curve, his speed at that position and of course the radius of the circle the curve is made from.
I hope someone can shed some light on this, I've been trying to work it out for awhile and can;t start coding the game until i have it nailed. I always been very interested in physics, I was very good at working out practical problems in school (though was never great when it came to adding the actual numbers together). I decided to do animation over physics when i left school, but i figure animation is largely the study of how things move, so i still get to think about problems like this.

hope you guys can help

thanks in advance :]
 
Physics news on Phys.org
Don't forget that physics is a secondary concern to gameplay! It's probably better just to make it do something that plays well.


I hope someone can shed some light on this, I've been trying to work it out for awhile and can;t start coding the game until i have it nailed.
That shouldn't be true at all! Not only can you start coding the other aspects of the game, but if you write well, you should just be able to code some simplistic loop handling mechanism, and replace it with a better one later. (In fact, even if you "knew" the mechanism you wanted to use, you should still code it in this way -- you might want to tweak things later!)



The simplest picture is to model your character as sliding along the loop, without any friction, or energy input. In this case you have:

(total energy) = (kinetic energy) + (gravitational potential energy) = (constant)

where

(kinetic energy) = (1/2) m v²
(gravitational potential energy) = m g h

where m is your character's mass, v is his velocity, g is the gravitational constant, and h is how high your character is.


So when you want to start using this model, you simply compute the total energy. Then, at all future times, you can simply solve the above equation for velocity. The only thing left to do is to is to figure out when your character should fall off the loop. (Or be launched into the air when he reaches a downward slope, or other similar things)


To move in a circle, the body must feel a normal force of exactly:

(normal force) = m v² / R

where R is the radius of the circle. Your character will fall when the normal component of the force of gravity is greater than this force.
 
I think that calculation based on the normal force is what you'd want to use in most circumstances since it's more flexible in case you want other things to happen while the character is going around the loop, and it requires you to keep track of less history (it might be part of your ground-character collision detection anyway). To make the character do impossible stunts, you could rig it so that gravity decreases as the character goes towards the top of the loop.

One game I really like, Fancy Pants Adventures (http://www.fancypantsadventures.com/ ) appears (I could be wrong) to make it so that before the normal force is calculated, if the character is running, an extra force pushes him into the ground as if he were a Formula 1 race car with spoilers (though the effect disappears as soon as he stops running). This allows him to go around impossible loops and run on the ceiling in some parts of the game.
 
Last edited by a moderator:
Well, a sonic type character goes -really fast-. I don't imagine that an extra force pressing him against the ground would be necessary for loops.

(As for when the ground starts sloping downwards, that's another story)
 
thats for you reply hurky. I think what you said makes sense.. but I'm a bit confused on how to go about implementing it..
I havn't really thought about using normals of force before. could you explain this a little more?

I'm going to try to explain the game problem in a little more detail so that we might understand each other a bit clearer. Firstly, I'm assuming on this curve that there is no friction, and all energy is reflected back in the player when he runs on it, as such, if there was no gravity the velocity of the character comming into the curve would be equal to the velocity of the character exiting it. I'm also pretty sure the velocity of the character will be directly porportional to it's Y position. however, the rate at which it decelerates changes as the the angle of the the chracter from the centre of the circle changes, and it is at this point that my head starts to spin :/. i need to be able to calculate the characters position in the next frame so i know where to tell the computer to draw him, and also to find out weather or not he is still in the curve. If he is not still in the curve i need to use another calculation to find out how much time passed since the last frame until he left the curve ,which could be 0.4866frames for example. i then calculate how far and where he will travel to in the game area outside of the curve in (1 - 0.4866)frames to find where to draw him in the next frame.

I know this is complicated, which may mean i need tocompletely replan how I'm going to code the game at a later point, which is why i can't start it now ~_~.

here's a drawing i did that attempts to explain how I'm thinking about this http://brian.gogoanime.com/gamePys.GIF

thanks again for your reply!
 
Last edited by a moderator:
Hurkyl said:
Don't forget that physics is a secondary concern to gameplay! It's probably better just to make it do something that plays well.


Not true...
check out the N(ninja) game
(google it)
It rocks cause of the physics
same thing with Halo 1
 
Thread 'Gauss' law seems to imply instantaneous electric field'
Imagine a charged sphere at the origin connected through an open switch to a vertical grounded wire. We wish to find an expression for the horizontal component of the electric field at a distance ##\mathbf{r}## from the sphere as it discharges. By using the Lorenz gauge condition: $$\nabla \cdot \mathbf{A} + \frac{1}{c^2}\frac{\partial \phi}{\partial t}=0\tag{1}$$ we find the following retarded solutions to the Maxwell equations If we assume that...
I passed a motorcycle on the highway going the opposite direction. I know I was doing 125/km/h. I estimated that the frequency of his motor dropped by an entire octave, so that's a doubling of the wavelength. My intuition is telling me that's extremely unlikely. I can't actually calculate how fast he was going with just that information, can I? It seems to me, I have to know the absolute frequency of one of those tones, either shifted up or down or unshifted, yes? I tried to mimic the...
Back
Top