- Home /
Question by
RePlexOfficial · Jun 19, 2018 at 04:52 PM ·
inputaxisverticalstrangescrollwheel
Input Scroll Wheel And Vertical Axis Work Together?
I use this (very simple) Script to control a cam. However, the vertical axis doesn´t only change the z-pos, but also the y-pos. The same thing occurs vice versa with Mouse ScrollWheel. I don´t know if I miss sth. important or not. Do you know why that happens?
public float speed = 50.0f;
private void Update()
{
float horizontal = Input.GetAxis( "Horizontal" );
float vertical = Input.GetAxis( "Vertical" );
float mouseWheel = Input.GetAxis( "Mouse ScrollWheel" );
transform.Translate( horizontal * speed * Time.deltaTime, mouseWheel * speed * Time.deltaTime, vertical * speed * Time.deltaTime );
if(transform.position.y < 1) {
Vector3 temp = transform.position;
temp.y = 1;
transform.position = temp;
}
}
Comment