Moving the player view - Weapon muzzle climb / recoil.

Discuss programming in the QuakeC language.
Post Reply
Ace12GA
Posts: 56
Joined: Sat Jan 28, 2012 12:08 am

Moving the player view - Weapon muzzle climb / recoil.

Post by Ace12GA »

I've been working on a mod for my own amusement, and to add some skill I wanted to have some of the weapons cause the view to move up each time the weapon was fired. The idea was to balance some of the more powerful automatic weapons I have added. It seemed easy, and the solution is, however I could not find it easily. It took probably 5 hours of experimenting, and searching, to finally figure out how to do it.

And no, self.punchangle does not create this effect; I wanted the actual aim point to climb each time the weapon was fired.

I ended up with this function that directly writes to the server to move the view.

Code: Select all

void(float vkick) WeaponRecoil =
{
	msg_entity = self;
	WriteByte(MSG_ONE, 10);
	WriteAngle(MSG_ONE, self.v_angle_x - vkick);
	WriteAngle(MSG_ONE, self.v_angle_y);
	WriteAngle(MSG_ONE, self.v_angle_z);
};
Used like this after the weapon fires:

Code: Select all

Fire_Weapon();
WeaponRecoil(4);
I thought it might be useful for someone trying to figure out how to make this work. It drove me nuts. Also, if someone knows a better way to do it, that would be great to know as well.
necros
Posts: 77
Joined: Thu Dec 16, 2004 10:32 pm

Re: Moving the player view - Weapon muzzle climb / recoil.

Post by necros »

you can force the player's viewpoint to snap to player.angle by setting player.fixangle to 1 as well. :)
Ghost_Fang
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Re: Moving the player view - Weapon muzzle climb / recoil.

Post by Ghost_Fang »

very handy! punchangle is all i ever knew, but i did know it didnt move the v_angle literally, but i used it anyways for the effect. :lol:
Post Reply