- Home /
Time.deltaTime not working?
Hello I am trying to make an aim down sights script and I was going off an online tutorial. For some reason when I do 10 Time.deltaTime, it seems to only move the gun 10 frames towards my end position vs if I do 10000 time.deltaTime it goes all the way to my end position but without any Slerp effect. Am i doing something wrong? Thank you :)
public Vector3 aimDownSights;
public Vector3 hipFire;
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(1))
{
transform.localPosition = Vector3.Slerp(transform.localPosition, aimDownSights, 10 * Time.deltaTime);
// transform.localPosition = Vector3.Slerp(transform.localPosition, aimDownSights, 10000 * Time.deltaTime);
// transform.localPosition = Vector3.Slerp(hipFire, aimDownSights, 10 * Time.deltaTime);
//transform.localPosition = aimDownSights;
}
Check Input.Get$$anonymous$$ouseButtonDown , Input.Get$$anonymous$$ouseButtonUp and Input.Get$$anonymous$$ouseButton
Answer by Bunny83 · Feb 13, 2019 at 11:00 PM
What you do wrong? You use an XXXXDown method which is only true for one frame when the button is pressed down. Instead of GetMouseButtonDown you want to use GetMouseButton instead which returns the current state of the button.
Your answer
Follow this Question
Related Questions
Unity ads problem 0 Answers
Ads on timers 0 Answers
How to disable animation.Play? (FPS) 1 Answer
How can I make an object always look at the mouse? 2 Answers
How to make a gun work with camera? 1 Answer