Sonic the hedgehog physics o_<

  • Context: Undergrad 
  • Thread starter Thread starter myutwo33
  • Start date Start date
  • Tags Tags
    Physics
Click For Summary

Discussion Overview

The discussion revolves around the physics involved in creating a Sonic the Hedgehog-style 2D platform game, specifically focusing on how to calculate the character's position and speed while running up a curved surface resembling the inside of a circle. Participants explore various physics principles and their implications for game design.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses the need to determine the character's position and speed on a curved surface based on initial conditions such as previous position and speed.
  • Another participant suggests that gameplay should take precedence over strict adherence to physics, proposing that initial coding can be done with simpler mechanics that can be refined later.
  • A different viewpoint emphasizes modeling the character as sliding along the loop without friction, using energy conservation principles to calculate future velocities.
  • Some participants propose using the normal force to determine when the character might fall off the loop, noting that this approach allows for flexibility in gameplay mechanics.
  • One participant mentions the possibility of modifying gravity to enable the character to perform stunts, referencing a specific game that implements such mechanics.
  • Another participant questions the necessity of additional forces to keep the character grounded during high-speed maneuvers, suggesting that the character's speed alone may suffice.
  • A participant seeks clarification on the implementation of normal forces and expresses confusion regarding the calculations needed to track the character's position and velocity accurately.
  • One participant references a game that successfully integrates physics into gameplay, arguing that well-implemented physics can enhance the gaming experience.

Areas of Agreement / Disagreement

Participants express a mix of opinions regarding the importance of physics in gameplay, with some advocating for a physics-first approach while others prioritize gameplay mechanics. The discussion remains unresolved with multiple competing views on how to balance these aspects.

Contextual Notes

Participants acknowledge the complexity of the calculations involved, particularly in relation to the character's deceleration and position tracking. There are also assumptions about the absence of friction and the conservation of energy that may not be universally accepted.

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 coming 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
 

Similar threads

  • · Replies 17 ·
Replies
17
Views
2K
  • · Replies 66 ·
3
Replies
66
Views
6K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 27 ·
Replies
27
Views
3K
  • · Replies 4 ·
Replies
4
Views
10K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 21 ·
Replies
21
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K