Okay, so I'm going to start working on this in pseudo-code form so I can get around it in my head.
Just for clarification I'm aiming for classic 2D sonic mechanics (Ie' those in sonic 1 and 2)
Gmod Wire Ranger: Fires a 'laser' from V1 to V2, reports if hits, distance, hisnormal of surface it hits.
I'm unsure about what I'll be using about using for ground detection, I'm thinking several rangers in 8, 10 or whatever directions around sonic, find out which ranger has the shortest distance and gets its hit normal, then fires another ranger at the hit normal and gets the distance
let's for now, assume sonic is a ball of '10' radius.
if SonicInAir = 1 {...
SmallestDistance = 10
for I=1,10 {
Angle = I*36
DirectionVector = vec(sin(Angle),cos(Angle))*10
RD = ranger(SonicPos,SonicPos+DirectionVector
if RD:hit & RD:distance =< SmallestDistance {
SmallestDistance = RD:distance
GroundNormal = RD:hitnormal
Hit = 1
}
}
if Hit{
RD = ranger(SonicPos,SonicPos+GroundNormal*-10)
GroundAngle = RD:hitNormal:toAngle
(assuming 90 is flat left ground)
SonicXVel = abs(sin(Angle))*SonicXVel
SonicYVel = abs(cos(Angle))*SonicYVel
Well, what I'm struggling with in my head is how Sonics velocities transition between angles and states and how gravity plays into it, am I to understand the only four states that sonic has are Sonic in air, Sonic 'Rolling' in air (ie; after a jump), sonic rolling on ground (Less friction), Sonic on ground regularly.
I tried looking at the MMF code however I find the whole grid-programing thing very unintuitive and hard to read, especially with all the MMF-specific stuff like 'fast loops' (Which I guess translate to for/while loops)?
I'm more looking for a generic explanation of sonic physics and how his velocities transition between states.