3 registered members (Konsti, AndrewAMD, 1 invisible),
1,376
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: angle adjustment
[Re: molotov]
#338562
08/19/10 07:41
08/19/10 07:41
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
Expert
|
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
I have this in one of my old codes:
// code lend from JulzMighty : http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=291799#Post291799
void alignToVec(ANGLE* entAng, VECTOR* vec, VECTOR* axis, var factor) {
vec_rotate(axis, entAng);
vec_normalize(axis, 1);
vec_normalize(vec, 1);
VECTOR rotAxis;
vec_cross(rotAxis, vec, axis);
var angle = -acos((float)vec_dot(axis, vec)) * factor * vec_length(rotAxis);
ANGLE rotAngle;
ang_for_axis(rotAngle, rotAxis, angle);
ang_add(entAng, rotAngle);
}
Look at the comment for credits and link to topic. regards,
|
|
|
Re: angle adjustment
[Re: molotov]
#338567
08/19/10 08:46
08/19/10 08:46
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
Expert
|
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
You are right indeed, I have it applied right after my gravity trace:
// do a trace to get the z position below the entity
tracePos = c_trace(my.x, vector(my.x, my.y, my.z - 500), IGNORE_FLAG2 | IGNORE_ME | IGNORE_PASSABLE | IGNORE_PUSH);
alignToVec(my.pan, normal, vector(0,0,1), 15); // awesome for scaling walls, bit useless in a beat em up
// set the position of the entity smoothly to the trace target
Even though you already found it out, I'm posting this for others to learn from as well The only thing that you could do to improve my code, is use math to do a trace depending on the characters rotation, rather then always straight down... regards,
|
|
|
|