Vice City Multiplayer
		VC:MP 0.4 (Beta) => Script Discussion => Topic started by: NE.Restricted on September 10, 2014, 10:21:35 pm
		
			
			- 
				I would like to calculate the forward point from an object.
 For example a car object is 120 degrees (rotated) so a function which when I want to move it forward by 1 point, I would write:
 whatever(startingpointx,spy,spz,angleofobject,amounttomoveforward);
 Anyone knows how it is done?
- 
				// [Ka]Juppi's func from http://forum.liberty-unleashed.co.uk/index.php/topic,398.0.html
 // ported to fit your needs
 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
 }
 usage:
 
 player.Pos = GetForwardPoint( FindVehicle(0) /* example */, FindVehicle(0).EulerAngle.z );
 
 You can modify it to your needs, it's from the unofficial forum
- 
				// [Ka]Juppi's func from http://forum.liberty-unleashed.co.uk/index.php/topic,398.0.html
 // ported to fit your needs
 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
 }
 usage:
 
 player.Pos = GetForwardPoint( FindVehicle(0) /* example */, FindVehicle(0).EulerAngle.z );
 
 You can modify it to your needs, it's from the unofficial forum
 
 Well how to specify how many points forward? I need this to make my plane and UFO in my server (and custom vehicles).
- 
				Help!
			
- 
				// [Ka]Juppi's func from http://forum.liberty-unleashed.co.uk/index.php/topic,398.0.html
 // ported to fit your needs
 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
 }
 usage:
 
 player.Pos = GetForwardPoint( FindVehicle(0) /* example */, FindVehicle(0).EulerAngle.z );
 
 You can modify it to your needs, it's from the unofficial forum
 
 Well how to specify how many points forward? I need this to make my plane and UFO in my server (and custom vehicles).
 
 
 Modify the 25.0 constants to however many X/Y units you want, and if you need to spawn something overhead just change the Z field of the Vector.