VC:MP 0.4 (Beta) > Script Discussion

using custom object as bullet

(1/2) > >>

Flockshot:
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.

heekz.shadow:
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.

Flockshot:
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.

Flockshot:
Anyone

thijn:

--- Code: ---// [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
}

--- End code ---

Object.MoveTo( GetForwardPoint( player.Pos, player.Angle ) )

Not tested, but it should give you an idea.

Navigation

[0] Message Index

[#] Next page

Go to full version