Raised This Month: $ Target: $400
 0% 

Solved [TF2] Turning Rockets 180 Degree HELP


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
J0BL3SS
Member
Join Date: Sep 2020
Location: vsh_sands_v3
Old 12-13-2020 , 04:24   [TF2] Turning Rockets 180 Degree HELP
Reply With Quote #1

Hello, I've tried all the vectoral angles but I haven't been able to turn the rocket exactly where the player fired. I Need Some Help

Code:
float flVel1[3], flAng[3], flOrigin[3], flVel2[3];
			GetEntPropVector(entity_projectile, Prop_Send, "m_vecOrigin", flOrigin);
			GetEntPropVector(entity_projectile, Prop_Data, "m_angRotation", flAng);
			
			if(pTurnIt == 1)
			{
				flAng[0] = flAng[0]*0.0;
				flAng[1] = flAng[1]*180.0;
				flAng[2] = flAng[2]*0.0;
				PrintToChatAll("Projectile Turned");
			}
			
			GetAngleVectors(flAng, flVel2, NULL_VECTOR, NULL_VECTOR);
			
			
			flVel1[0] = flVel2[0]*1100.0; //Speed of a tf2 rocket.
			flVel1[1] = flVel2[1]*1100.0;
			flVel1[2] = flVel2[2]*1100.0;
			
			SetEntityGravity(entity_projectile, 1.0);
			TeleportEntity(entity_projectile, flOrigin, flAng, flVel1); //1100 vel speed
__________________
My Steam Profile
My Discord Name: J0BL3SS#5320



Last edited by J0BL3SS; 12-21-2020 at 12:00. Reason: Solved
J0BL3SS is offline
J0BL3SS
Member
Join Date: Sep 2020
Location: vsh_sands_v3
Old 12-13-2020 , 05:34   Re: [TF2] Turning Rockets 180 Degree
Reply With Quote #2

Code:
float flVel1[3], flAng[3], flOrigin[3], flVel2[3], flAng2[3];
			GetEntPropVector(entity_projectile, Prop_Send, "m_vecOrigin", flOrigin);
			GetEntPropVector(entity_projectile, Prop_Data, "m_angRotation", flAng);
			
			if(pTurnIt == 1)
			{
				flAng2[0] = flAng[0]*0.0;
				flAng2[1] = flAng[1]*180.0;
				flAng2[2] = flAng[2]*0.0;
				PrintToChatAll("Projectile Turned");
				
				GetAngleVectors(flAng2, flVel2, NULL_VECTOR, NULL_VECTOR);
			
			
				flVel1[0] = flVel2[0]*1100.0; //Speed of a tf2 rocket.
				flVel1[1] = flVel2[1]*1100.0;
				flVel1[2] = flVel2[2]*1100.0;
				
				SetEntityGravity(entity_projectile, 0.07);
				TeleportEntity(entity_projectile, flOrigin, flAng2, flVel1); //1100 vel speed
			}
			else if(pTurnIt == 0)
			{
				GetAngleVectors(flAng, flVel2, NULL_VECTOR, NULL_VECTOR);
				
				
				flVel1[0] = flVel2[0]*1100.0; //Speed of a tf2 rocket.
				flVel1[1] = flVel2[1]*1100.0;
				flVel1[2] = flVel2[2]*1100.0;
				
				
				SetEntityGravity(entity_projectile, 1.0);
				TeleportEntity(entity_projectile, flOrigin, flAng, flVel1); //1100 vel speed
			}
else
{
blah blah...
}
Tried This too but didnt worked
__________________
My Steam Profile
My Discord Name: J0BL3SS#5320



Last edited by J0BL3SS; 12-13-2020 at 06:54. Reason: Changed Code
J0BL3SS is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 12-20-2020 , 05:34   Re: [TF2] Turning Rockets 180 Degree HELP
Reply With Quote #3

i am just giving my two cent. i personally never try but you may test negate the velocity value like so.

PHP Code:
float vecVelocity[3];
GetEntPropVectorrocketProp_Data"m_vecVelocity"vecVelocity );
vecVelocity[0] *= -1.0;
vecVelocity[1] *= -1.0;
vecVelocity[2] *= -1.0;
SetEntPropVectorrocketProp_Data"m_vecVelocity"vecVelocity ); 
you may also try

PHP Code:
TeleportEntityrocketNULL_VECTORNULL_VECTORvecVelocity); 
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 12-20-2020 , 07:00   Re: [TF2] Turning Rockets 180 Degree HELP
Reply With Quote #4

To negate a vector you should use NegateVector.

If you want to rotate vectors to specific degree try this (took from SMLIB):
Code:
/**
 * Rotates a vector around its zero-point.
 * Note: As example you can rotate mins and maxs of an entity and then add its origin to mins and maxs to get its bounding box in relation to the world and its rotation.
 * When used with players use the following angle input:
 *   angles[0] = 0.0;
 *   angles[1] = 0.0;
 *   angles[2] = playerEyeAngles[1];
 *
 * @param vec 			Vector to rotate.
 * @param angles 		How to rotate the vector.
 * @param result		Output vector.
 * @noreturn
 */
stock void RotateVector(const float vec[3], const float angles[3], float result[3]) {
	float sinAlpha, sinBeta, sinGamma;
	float cosAlpha, cosBeta, cosGamma;

	{
		// First the angle/radiant calculations
		float rad[3];
		// I don't really know why, but the alpha, beta, gamma order of the angles are messed up...
		// 2 = xAxis
		// 0 = yAxis
		// 1 = zAxis
		rad[0] = DegToRad( angles[2] );
		rad[1] = DegToRad( angles[0] );
		rad[2] = DegToRad( angles[1] );

		// Pre-calc function calls
		cosAlpha = Cosine( rad[0] );
		sinAlpha = Sine( rad[0] );
		cosBeta  = Cosine( rad[1] );
		sinBeta  = Sine( rad[1] );
		cosGamma = Cosine( rad[2] );
		sinGamma = Sine( rad[2] );
	}

	// 3D rotation matrix for more information: http://en.wikipedia.org/wiki/Rotation_matrix#In_three_dimensions
	float x = vec[0], y = vec[1], z = vec[2];

	{
		float newX, newY, newZ;
		newY = ( cosAlpha * y ) - ( sinAlpha * z );
		newZ = ( cosAlpha * z ) + ( sinAlpha * y );
		y = newY;
		z = newZ;

		newX = ( cosBeta * x ) + ( sinBeta * z );
		newZ = ( cosBeta * z ) - ( sinBeta * x );
		x = newX;
		z = newZ;

		newX = ( cosGamma * x ) - ( sinGamma * y );
		newY = ( cosGamma * y ) + ( sinGamma * x );
		x = newX;
		y = newY;
	}

	// Store everything...
	result[0] = x;
	result[1] = y;
	result[2] = z;
}
__________________

Last edited by MAGNAT2645; 12-20-2020 at 07:06.
MAGNAT2645 is offline
J0BL3SS
Member
Join Date: Sep 2020
Location: vsh_sands_v3
Old 12-21-2020 , 12:01   Re: [TF2] Turning Rockets 180 Degree HELP
Reply With Quote #5

Quote:
Originally Posted by GsiX View Post
i am just giving my two cent. i personally never try but you may test negate the velocity value like so.

PHP Code:
float vecVelocity[3];
GetEntPropVectorrocketProp_Data"m_vecVelocity"vecVelocity );
vecVelocity[0] *= -1.0;
vecVelocity[1] *= -1.0;
vecVelocity[2] *= -1.0;
SetEntPropVectorrocketProp_Data"m_vecVelocity"vecVelocity ); 
you may also try

PHP Code:
TeleportEntityrocketNULL_VECTORNULL_VECTORvecVelocity); 
Thanks, i wasn't know i can do with negate velocity value, (vecVelocity[1] *= -1.0; for Yaw so i should change that)
__________________
My Steam Profile
My Discord Name: J0BL3SS#5320


J0BL3SS is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:39.


Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Theme made by Freecode