Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Issue with converting a facing to a Vector3.Z value to look at
Issue with converting a facing to a Vector3.Z value to look at [message #464420] Wed, 14 March 2012 15:27 Go to previous message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma:
General (4 Stars)
I'm working on a modified spectate plugin that adds a feature to automatically follow a player (by attaching the player to the head bone of the guy to follow) and also have it automatically follow the camera of the guy that's being followed, what I'm using now works with X and Y but it doesn't work correctly with the Z-height. This is what I'm using:

void Iran_Spectate_Follow_Camera_Player::Timer_Expired(GameObject *o, int number)
{
	if(number == 1)
	{
		GameObject *Player = Get_GameObj(ID);
		if(o && Player)
		{
			float facing_spectatedguy;			
			float PI = 3.14159265f;
			Vector3 pos2 = Commands->Get_Bone_Position(Player,"c head");

			facing_spectatedguy = Commands->Get_Facing(Player);

			pos2.X += 20.0f*(cos(facing_spectatedguy*PI/180));
			pos2.Y += 20.0f*(sin(facing_spectatedguy*PI/180));
			pos2.Z += 20.0f*(sin(facing_spectatedguy*PI/180)); 

			Force_Camera_Look_Player(o,pos2);
			Commands->Start_Timer(o,this,0.05f,1); // Loop
		}
	}
}


The Z-height of the camera is always off. I'm attaching the guy to the head of the other guy that he's following, according to Commands->Get_Position() this causes the position of both players be the same. I have the following two questions:

1. Is the way I calculate the Z-Height (pos2.Z in my case) correct?
2. Is it actually possible to get this correctly working, as third person and first person targeting have different Z-height from my experience?


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Wed, 14 March 2012 15:34]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: just wondering : weaponbagclass
Next Topic: ssgm wont load custom objects.gm
Goto Forum:
  


Current Time: Thu Nov 21 11:26:20 MST 2024

Total time taken to generate the page: 0.00655 seconds