AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [ H3LP ] Rotate angle vector (https://forums.alliedmods.net/showthread.php?t=308451)

CrazY. 06-20-2018 18:05

[ H3LP ] Rotate angle vector
 
Hello, I want to set view angle in player relative to wall angle. I tried with GL_trace_plane_normal, it's working but not as an I want. I want to aim in wall direction, not in oposite direction of wall. How I can rotate this vector to opositional direction?

Code:
new Float:vPlane[3], Float:vAngles[3]; get_global_vector(GL_trace_plane_normal, vPlane); vector_to_angle(vPlane, vAngles); set_entvar(this, var_v_angle, vAngles); set_entvar(this, var_fixangle, 1);

CrazY. 06-20-2018 21:08

Re: [ H3LP ] Rotate angle vector
 
Basically what I need is to rotate the yaw (vAngles[1]). So if the wall is located at 90 °, the aim is being set to 270 °, I want to set the aim in 90 °.

Code:

Wall        | Aim                | Aim that I want
--------------------------------------
90 °        | 270 °        | 90 °
270 °        | 90 °                | 270 °
180 °        | 360 °        | 180 °
360 °        | 180 °        | 360 °

https://image01.ipracticemath.com/co...s-radians1.png

Sorry for bump.

Natsheh 06-21-2018 02:37

Re: [ H3LP ] Rotate angle vector
 
PHP Code:

get_tr2(traceTR_flFractionfraction)
    
// If we didn't hit anything, then we won't get a valid TR_vecPlaneNormal.
    
if (fraction == 1.0) return
    
    new 
Float:normal[3]
    
get_tr2(traceTR_vecPlaneNormalnormal)
    
// We'll multiply the the normal vector by a scalar to make it longer.
    
normal[0] *= 400.0 // Mathematically, we multiplied the length of the vector by 400*(3)^(1/2),
    
normal[1] *= 400.0 // or, in words, four hundred times root three.
    
normal[2] *= 400.0 

You might get false result because you are not checking if the trace hit something transfer the vector into angles and it should give you the angles of the wall.

If i am wrong can you explain more of what are you doing?

CrazY. 06-21-2018 09:16

Re: [ H3LP ] Rotate angle vector
 
I'm trying to make a wall climb with "stuck". So basically, the player don't need to keep pressing IN_USE to climb. That's already working, but I need to EV_INT_fixangle/pev_fixangle in the player in the wall direction, so I don't need trace, only the plane.

So if I climb the wall that is in my front, the camera should keep aiming in this wall.


But what's really happening is the camera is being set to backward.


I hope you understand. If not I can show the code or enable the plugin in a test server.

klippy 06-21-2018 09:24

Re: [ H3LP ] Rotate angle vector
 
So it's always the opposite? Then just negate the direction vector before converting to angles.
Code:

xs_vec_neg(vPlane, vPlane);

CrazY. 06-21-2018 09:29

Re: [ H3LP ] Rotate angle vector
 
Works just fine, thanks.


All times are GMT -4. The time now is 12:20.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.