Liberty Unleashed

Scripting => Script Snippets => Topic started by: Vortrex on March 14, 2013, 05:27:57 pm

Title: Vortrex's Helpful Snippets
Post by: Vortrex on March 14, 2013, 05:27:57 pm
Here's a couple of snippets for everybody to enjoy.

First, here's a function to return the vector in front of a vector. All you need to calculate this is the current position to get the front of, the angle to calculate, and the distance away from the current position. This function can be used on both server and client side (depending on what script you put it in).
Code: [Select]
function GetVectorInFrontOfVector(vector,angle,distance)
{
angle = angle * PI / 180;
local x = (vector.x + ((cos(angle + (PI/2)))*distance));
local y = (vector.y + ((sin(angle + (PI/2)))*distance));
return Vector(x,y,vector.z);
}

Below is the same type of function, but is used to get a vector behind a vector.
Code: [Select]
function GetVectorBehindVector(vector,angle,distance)
{
angle = angle * PI / 180;
local x = (vector.x + ((cos(-angle + (PI/2)))*distance));
local y = (vector.y + ((sin(-angle + (PI/2)))*distance));
return Vector(x,y,vector.z);
}
Title: Re: Vortrex's Helpful Snippets
Post by: Shadow. on March 15, 2013, 04:59:32 pm
Why do people always have to create new topics....

http://forum.liberty-unleashed.co.uk/index.php/topic,1594.msg9154.html#msg9154 (http://forum.liberty-unleashed.co.uk/index.php/topic,1594.msg9154.html#msg9154)

If you have useful snippets, post them over here.
Title: Re: Vortrex's Helpful Snippets
Post by: Vortrex on March 15, 2013, 06:30:09 pm
Why do people always have to create new topics....

Maybe because the part of the forum for script snippets is a section and not a thread? What happens if you ever decide to delete your original post and I had a reply on it with more snippets? That's why I make my own threads.

EDIT: I used the word thread, but is also for topic