AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Origin based on where the player looks (https://forums.alliedmods.net/showthread.php?t=196093)

Backstabnoob 09-15-2012 09:00

Origin based on where the player looks
 
How do I move the origin by 100.0 depending on where the player looks? I cannot add 100 to X or Y origin, because it may be 100 to his back or side.

jimaway 09-15-2012 09:11

Re: Origin based on where the player looks
 
did you even search before posting?
https://forums.alliedmods.net/showthread.php?t=93773

Backstabnoob 09-15-2012 09:21

Re: Origin based on where the player looks
 
Yes I do, that code is not what I'm looking for though. I could have explained better.

I mean on ground - if the player's origin is x = 1000, y = 1000 and he's turned to the X axis, I need to get x = 1100 and y = 1000 origin. I don't know how to calculate it. Z axis cannot be taken in account.

jimaway 09-15-2012 09:30

Re: Origin based on where the player looks
 
what if player is looking straight between x and y axis? (at 45 degrees angle)

Backstabnoob 09-15-2012 09:36

Re: Origin based on where the player looks
 
1 Attachment(s)
His origin + 100 depending on the angle he's aiming at.

jimaway 09-15-2012 09:46

Re: Origin based on where the player looks
 
use the code in the link i gave you, just dont change z origin?

Code:
new pOrigin[3],tOrigin[3] get_user_origin(id,pOrigin) get_user_origin(id,tOrigin,3) tOrigin[2] = pOrigin[2] if( get_distance(pOrigin, tOriign) > 100 ) {     new vector[3];     vector[0] = tOrigin[0] - pOrigin[0];     vector[1] = tOrigin[1] - pOrigin[1];     vector[2] = tOrigin[2] - pOrigin[2];         new Float:fVector[3];     IVecFVec(vector, fVector);         new Float:length = vector_length(fVector);         fVector[0] = fVector[0] / length * 100;     fVector[1] = fVector[1] / length * 100;     fVector[2] = fVector[2] / length * 100;         FVecIVec(fVector, vector);         tOrigin[0] = pOrigin[0] + vector[0];     tOrigin[1] = pOrigin[1] + vector[1];     tOrigin[2] = pOrigin[2] + vector[2]; } set_user_origin(id, tOrigin)

something like this

Backstabnoob 09-15-2012 09:49

Re: Origin based on where the player looks
 
No, it doesn't work the way I need at all.

jimaway 09-15-2012 09:59

Re: Origin based on where the player looks
 
how do you need it then lol? it does what the picture shows

Liverwiz 09-15-2012 11:01

Re: Origin based on where the player looks
 
get_user_origin(id, origin, mode=3)

Notes:

Modes:

0 - current position.
1 - position from eyes (weapon aiming).
2 - end position from player position.
3 - end position from eyes (hit point for weapon).
4 - position of last bullet hit (only CS).


That what you're looking for? granted, it won't be 100 units, but you could trim it down by using mode 1 and 3. Though this will raise your position a bit because its from the eyes, not the ground/feet.

fearAR 09-17-2012 17:09

Re: Origin based on where the player looks
 
PHP Code:


new Float:fOrigin], Float:fViewOfs], Float:fViewAngles], Float:fEndOrigin], Float:fMagnitude;

pevidpev_originfOrigin ); // Obtain user origin
pevidpev_view_ofsfViewOfs ); // Obtain user eye position

fOrigin] += fViewOfs]; // Add eye position to origin
fOrigin] += fViewOfs];
fOrigin] += fViewOfs];

pevidpev_v_anglefViewAngles ); // Obtain View angles ( pitch yaw roll ) of the user camera
engfuncEngFunc_MakeVectorsfViewAngles ); // Make vectors from the viewangles
global_getglb_v_forwardfViewAngles ); // Obtain vector relationed FORWARD

fMagnitude floatsqroot( ( fViewAngles] * fViewAngles] ) + ( fViewAngles] * fViewAngles] ) + ( fViewAngles] * fViewAngles] ) ); // Obtain magnitude from forward viewangles vector

fViewAngles] /= fMagnitude// Obtain the normalized vector
fViewAngles] /= fMagnitude;
fViewAngles] /= fMagnitude;

fMagnitude 100.0// Change magnitude

fViewAngles] *= fMagnitude// advance the normalized vector by magnitude = 100.0
fViewAngles] *= fMagnitude;
fViewAngles] *= fMagnitude;

fEndOrigin] = fOrigin] + fViewAngles]; // Add Viewing angles direction to user origin
fEndOrigin] = fOrigin] + fViewAngles];
fEndOrigin] = fOrigin] + fViewAngles]; 

Greetings.


All times are GMT -4. The time now is 08:16.

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