To do any offset of a vector to a new location you take the direction you
wish to go. Forward, -forward(back), right, -right(left), up, -up(down) and
you multiply it times the distance to offset and then add it to the vector,
so the negative directions are really just subtractions.

So examples:

GetAbsOrigin() + (forward * 200.0f) - Gives you the entity origin offset
forward 200 units.
vecShotSrc - (up * 32.0f) - Gives you the source of the shot offset down by
32 units.

GetAbsOrigin() + (forward * 10.0f) - (right * 25.2f) - This one offsets the
vector forward 10 units and 25.2 units to the left.

There are also more complex ways to do offsets using trigonometric functions
(sine, cosine, tangent) which give you the benefit of generating forward and
right vectors based on the angle you wish to move in. It is basically
solving a right triangle where the right vector is opposite the angle and
the forward vector is adjacent to the angle and the directional vector is
the hypotenuse.

Chris
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonas 'Sortie'
Termansen
Sent: Monday, October 13, 2008 7:48 PM
To: Discussion of Half-Life Programming
Subject: Re: [hlcoders] Using vectors to offset.

If you want to lower a vector, simply decrease the .z value?

----- Original Message ----- 
From: "Luke Smith" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, October 14, 2008 1:23 AM
Subject: [hlcoders] Using vectors to offset.


> Can someone explain to me how to use vectors to offset things like
> attachments.
> The code I'm looking at looks like this;
>
>
> Vector forward, right;
>
> CBasePlayer *pPlayer = ToBasePlayer( this );
>
> pPlayer->EyeVectors( &forward, &right, NULL );
>
> *pVecTracerStart = vecShotSrc + Vector ( 0 , 0 , -4 ) + right * -5 + 
> forward
> * 45;
>
>
>
> So adjusting the number on the bottom like "45"  has an effect and offsets
> the attachment forwards. But what if I want to move it down for instance?
> Ive tried putting Vector forward, right, down; and so on but it has no
> effect. Anyone?
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives, 
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
> 


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to