- Home /
Question by
dendens2 · Apr 03, 2013 at 07:01 PM ·
javascriptsmoothdamp
My rotation affects a value it should not.
Ok, first off, sorry for asking a lot of questions, I have a lot of problems, lol. Anyways,I have this system (based on Eeteski's but changed) to count how much "steps" I took (even though it does not actually do that) and then adds bob to the gun. The step counter looks like it works the same no matter what direction I am facing, but something it the SmoothDamp is screwing up and adding more or less bob depending on which direction I am facing.
//Variables
var gunBobAmountX: float = 0.05;
var gunBobAmountY: float = 0.025;
var gunBobSpeed:float = 1;
var currentGunBobX: float;
var currentGunBobY: float;
var stepCounter: float;
var gunBobXVelocity: float;
var gunBobYVelocity: float;
//The top three variables' values have been changed in the inspector.
//code
//Counts the amount of distance moved
stepCounter += walkScript.aimingWalkSpeed * gunBobSpeed * Time.deltaTime;
//Bobs the gun
if ((Input.GetAxis("Horizontal") || Input.GetAxis("Vertical")) && walkScript.GetComponent(PlayerMovementScript).grounded == true)
{
currentGunBobX = Mathf.SmoothDamp(currentGunBobX, Mathf.Sin(stepCounter) * gunBobAmountX, gunBobXVelocity, stopBobTime);
currentGunBobY = Mathf.SmoothDamp(currentGunBobY, Mathf.Cos(stepCounter * 2) * -1 * gunBobAmountY, gunBobYVelocity, stopBobTime);
}
else
{
currentGunBobX = Mathf.SmoothDamp(currentGunBobX, Mathf.Sin(timer ) * standingGunBobAmountX, gunBobXVelocity, stopBobTime);
currentGunBobY = Mathf.SmoothDamp(currentGunBobY, Mathf.Cos(timer) * -1 * standingGunBobAmountY, gunBobYVelocity, stopBobTime);
}
I don't understand what can possibly be affected based on what direction I am facing/moving. Thanks!
Comment
Your answer
Follow this Question
Related Questions
Can I convert unityscript to boo? 0 Answers
Dynamically load UnityScript file 1 Answer
If you destroy a List of Class objects... 1 Answer