r/howdidtheycodeit • u/Master_Sketcher • Jan 03 '22
Question How did they code the gravity for the characters in SA2?
I've always wondered what weird way they programmed the gravity in Sonic Adventure 2, as in how the characters fall, because there are sections especially in places like Final Rush/Final Chase where when they'll jump; they won't fall downwards, they'll fall back in the direction they came from; like if you jumped off a 45 slanted road, you'd be pulled back in the direction that you jumped off that road from, instead of the actual direction of gravity.
12
Upvotes
14
u/pibbs Jan 04 '22
Apply gravity along the normal vector of the last ground surface?
4
u/yboy403 Jan 04 '22
To elaborate on the other comment, two possible ways would be:
Remember that gravity is arbitrary in game physics. Engines like Unity let you check a box that automatically applies -9.81m/s² along the Y axis and calls it "gravity", but if you're any kind of competent developer you can disable that and write your own physics.
And like they pointed out, an easy way to do that would be to find the normal vector (an imaginary line pointing straight out of a surface, perpendicularly) of a nearby surface, and apply some velocity in that direction to simulate gravitational pull.