- Home /
This question was
closed Sep 15, 2014 at 09:59 AM by
RedDevil for the following reason:
Other
Increase/reset speed on tilt
Hi! So what I am trying to do is have my character go in the tilt direction at an increasing speed.If the character changes drection then the speed resets to a value and then starts increasing again.The problem I am facing is that alot of time the speed remains the same and does not increase/reset all the time.The tilt and everything else works perfectly.Here is some code and i hope you can help.Thank you.
speed=1;
targetspeed = 4;
void Update()
{
speed = Mathf.SmoothDamp(speed, targetSpeed, ref speedDV, 0.5f);
if(tiltright)
{
speed = 1,5f;
speed = Mathf.SmoothDamp(speed, targetSpeed, ref speedDV, 0.5f);
rigidbody2D.velocity = transform.TransformDirection(Rdirection * speed);
}
//same for tiltright
}
Comment