Sign in to follow this  
speciesUnknown

Need a nice time independent, nonlinear recoil recovery function

Recommended Posts

This is the prototype I currently have, whereby the player is "distracted" by recoil and their accuracy is affected. At exactly 60hz it looks exactly like I want. Its nonlinear, so if a weapon recoils faster than you can recover from it, there is a threshold where recoil and recovery are in equilibrium. (as if the player is holding the gun more firmly, at the cost of fine motor skills, to recover from heavy recoil)
	void ZombieGameCreature::hearWeaponFire(shared_ptr<Weapon> w, shared_ptr<Logic::Shot> shot)
	{
		if(w == this->primary_weapon || w == this->secondary_weapon)
		{
			this->aim_distraction += w->properties->recoil;
		}
	}

	void ZombieGameCreature::update(float delta)
	{
		Logic::Creature::update(delta);
		this->aim_distraction -= (10.f + 0.5f * (aim_distraction * aim_distraction)) * delta;
		if(aim_distraction < 0)
			aim_distraction=0;
		
	}


This has a few problems; namely, its not time independent; the hard coding is also an issue but ill fix that when ive got the right function. I'm not yet decided what will be the input variables; (currently as you can see they are hard coded) but I dont mind having a few functor objects, or exposing the variables as properties of the character. I've tried it with a few weapons; an SMG with very little recoil and a .50 machine gun which takes two people to carry and would break whatever part of your body you brace it against if you tried to fire from the hip :P I want as few variables as possible, as there is little benefit to having a zillion variables to balance; I've seen games with far too many variables involved in weapon balancing... Any ideas?

Share this post


Link to post
Share on other sites
Ahh, yes i actually meant to choose game programming, but it is late at night :P


As an extra bit of information which might make a difference, the recoil is indicated to the user through a dynamic crosshair:



This will also affect the user's ability to aim and should be considered.

Yes, the player is wielding two machine guns.

Yes, the player is made of wood and wearing a cape. Placeholder artwork FTW.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this