1 registered members (henrybane),
530
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Walking on surfaces and adjusting angles
#291741
09/27/09 17:38
09/27/09 17:38
|
Joined: Oct 2007
Posts: 306 Austria
Alan
OP
Senior Member
|
OP
Senior Member
Joined: Oct 2007
Posts: 306
Austria
|
Hi guys,
I'm currently doing a fan-fic of Sonic the Hedgehog. As you probably know, Sonic is able to run enormously FAST and capable of running up walls, ceilings, loopings and so on. I've got the gravity in place, the overall movement is up and running, but I need to get the TILT and ROLL angles right for my model, because its feet are supposed to face the ground at any time, even while running in a looping (so at the highest point of a looping, the model is supposed to be upside-down, when running up a wall, feet, body and head should be aligned in a horizontal manner instead of a vertical and so on). So, I had a look at the c_trace-command. It modifies the "target" vector and the "normal" vector, the latter giving us the normal of the hit surface (therefore the normal of the surface we are currently walking/running on). The question is: how do I convert the normal vector of the surface the model is currently walking on into tilt and roll angles so that Sonics feet point towards the ground?
Greets and thanks in advance!
Alan
|
|
|
Re: Walking on surfaces and adjusting angles
[Re: DJBMASTER]
#291769
09/27/09 19:52
09/27/09 19:52
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
i think c_trace and normal vector + vec_to_angle is what you want.
3333333333
|
|
|
Re: Walking on surfaces and adjusting angles
[Re: Quad]
#291800
09/28/09 04:01
09/28/09 04:01
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
It seems to be quite a popular problem these days. I just put up a contribution under "Lite-C Contributions" that should help you out.
It's a function that takes an angle and two vectors (one from the world -- using "normal" after c_trace or c_move makes sense -- and one local vector that you want to align with the world one -- using "vector(0, 0, 1)" will make Sonic's feet line-up on the surface underneath him), and modifies the angle so that it lines up.
It doesn't use vec_to_angle.
Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: Walking on surfaces and adjusting angles
[Re: Alan]
#291914
09/28/09 21:52
09/28/09 21:52
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
It allows the function to be more general:
It will *always* be (0, 0, 1) if you want Sonic's feet to face the surface underneath them (that is, the function will line up Sonic's "up" with the surface normal). If you use (1, 0, 0), Sonic's back will line up with the surface you c_trace, since it'll line up Sonic's local x-axis with the surface normal (this would be similar to "vec_to_angle", except the roll won't necessarily be zero, since only the smallest rotation possible is done to line the angle up).
Don't forget to rotate Sonic's pan relative to his current orientation (using ang_rotate or c_rotate(..., USE_AXIS)) instead of just adding or subtracting to his pan.
Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: Walking on surfaces and adjusting angles
[Re: JibbSmart]
#291917
09/28/09 22:03
09/28/09 22:03
|
Joined: Oct 2007
Posts: 306 Austria
Alan
OP
Senior Member
|
OP
Senior Member
Joined: Oct 2007
Posts: 306
Austria
|
@JulzMighty: Oh, I see, now I get the hang in it! I will definitly try your function tomorrow, sounds really great, logical and easy to use. Thanks for your explanation Greets and thanx Alan
|
|
|
|