- Home /
Mathf iphone input
Hi, can someone please help me, I've got this strange problem when I simulate Unity wireless on my iPhone 4 with the Unity app it runs as expected, but when I compile it to my phone the animation starts without any input, I've posted the code below.
//Slowly face towards direction of movement
var lookAt = t.position + movement.y * camForward + movement.x * camRight;
//Calculate desired lookAt position
//If there's movement
if(!Mathf.Approximately(movement.y, 0) || !Mathf.Approximately(movement.x, 0)) {
animateCntrl.Walk();
var rot = t.rotation.eulerAngles; //Save current rotation
t.LookAt(lookAt); //Set transform to look at the desired lookAt position
var newYRot = t.rotation.eulerAngles.y; //Save the new y rotation
var smoothYRot = Mathf.SmoothDampAngle(rot.y, newYRot, yVelocity, rotationDamping);
rot.y = smoothYRot;
t.rotation = Quaternion.Euler(rot); //Assign new rotation
}
Forgot to say only the animation starts, he don't move until I touch the screen.
And animateCntrl is a var to a script holding all my animations.
Think I know it's something to do with Mathf.Approximately returning incorrect but not sure how to correct it?
Please format your code properly in the future - help other help yourself.
Your answer
![](https://koobas.hobune.stream/wayback/20220612145937im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Working with Touch screens... 1 Answer
Joystick / Button 3 Answers
The New Google Cardboard Button Input? 0 Answers
Ray error with touches.position 1 Answer
The iPhoneInput.touchCount is 1 while no touch actually. 1 Answer