Vice City Multiplayer
VC:MP 0.4 (Beta) => Script Discussion => Topic started by: Flockshot on September 29, 2014, 06:35:56 pm
-
I have an idea to use a custom object as a bullet but there is a problem.
I can make that object and also move it.But the problem is that how do I figure out in which direction to move.
For Example: I used it but i am pointing it a little away from straight but the object goes straight and missing the player.
Can anyone give any idea so that i can move object to where the player points.
I know its possible.
-
If you are good with math, it's extremely easy.
You can also search this forum and the unofficial one, it's been answered plenty of times.
-
I am good at math but dont know the equation to be used for it.
and i dont seem to find any on the forum.
-
Anyone
-
// [Ka]Juppi's func from http://forum.liberty-unleashed.co.uk/index.php/topic,398.0.html
function GetForwardPoint( pos, angle ) // you must pass an angle in degrees
{
local rad = angle * PI / 180; // we convert to radians
local x = pos.x, y = pos.y;
local x2 = x + 1.0 * cos(rad) - 25.0 * sin(rad); // we calculate
local y2 = y + 1.0 * sin(rad) + 25.0 * cos(rad);
return Vector( x2, y2, pos.z ); // return a vector
}
Object.MoveTo( GetForwardPoint( player.Pos, player.Angle ) )
Not tested, but it should give you an idea.
-
// [Ka]Juppi's func from http://forum.liberty-unleashed.co.uk/index.php/topic,398.0.html
function GetForwardPoint( pos, angle ) // you must pass an angle in degrees
{
local rad = angle * PI / 180; // we convert to radians
local x = pos.x, y = pos.y;
local x2 = x + 1.0 * cos(rad) - 25.0 * sin(rad); // we calculate
local y2 = y + 1.0 * sin(rad) + 25.0 * cos(rad);
return Vector( x2, y2, pos.z ); // return a vector
}
Object.MoveTo( GetForwardPoint( player.Pos, player.Angle ) )
Not tested, but it should give you an idea.
That just move the object in only 1 place no matter what the angle is.
About u saying that it can give me idea i cant understand it.
I dont know about PI,cos,sin i am just in class 8 and it haven't been taught to us.
-
Then it's probably a good idea to find something else to do.
-
If i remember correctly there was a ramp function in your,stormues test server that make a ramp in front of player
Is it possible to give me that.
-
That's the code I posted.
-
That's the code I posted.
Then that code should work.