Can anyone help adding Time.deltaTime to this script? I’m not sure in how many positions it needs to be placed. It’s for a camera bob script.
For example, if I do
var translateChange = waveslice * bobbingAmount * Time.deltaTime;
then…
translateChange = totalAxes * translateChange;
…should be * Time.deltaTime also?
var moveTouchPad : Joystick;
private var timer = 0.0;
var bobbingAmount = 0.2;
var midpoint = 2.0;
var speedLeft = 0.3;
var speedRight = 0.4;
var speedForward = 0.4;
var speedBack = 0.3;
function Update ()
{
if (moveTouchPad.position.y > 0 || moveTouchPad.position.y < 0 || moveTouchPad.position.x > 0 || moveTouchPad.position.x < 0)
{
var waveslice = 0.0;
if (Mathf.Abs(1) == 0 && Mathf.Abs(1) == 0)
{
timer = 0.0;
}
else
{
waveslice = Mathf.Sin(timer);
// FORWARD
if (moveTouchPad.position.y > 0)
timer += (moveTouchPad.position.y * speedForward); // INCREMENT TIMER
// RESET TIMER
if (timer > Mathf.PI * 2)
timer -= (Mathf.PI * 2);
}
// MOVE CAMERA
if (waveslice != 0)
{
var translateChange = waveslice * bobbingAmount;
var totalAxes = Mathf.Abs(1) + Mathf.Abs(1);
totalAxes = Mathf.Clamp (totalAxes, 0.0, 1.0);
translateChange = totalAxes * translateChange;
transform.localPosition.y = midpoint + translateChange;
if (translateChange <= (-0.05));
}
else
{
transform.localPosition.y = midpoint;
}
}
}