- Home /
Inspection camera script problem
Hello everyone.
I'm brand new Unity user and was just doing my first steps with Unity scripting. I even wrote my first camera script. It allows me to make my camera rotate around "observed" object in some specific way...
Thing is my script is working fine with Unity "play mode" as well as exported as a web player application. Things get much worse when I export it as windows "*.exe" file. I run it on the same computer but this time it is working much slower. I don't mean FPS rate but all the distanced that are calculated per frame are very small ( I hope you know what i mean ). It's even more strange when I try to run in on different computers. Exe file works fine on some machines and works "slow" on others... why ?? As i said its not a matter of fps rate. I also used Time.deltaTime factor while calculations so it should be frame independent... shouldn it ?
Does anyone have any idea what could be the reason of such behaviour ?
I couldn't make my script display properly so please find it here: http://www.nopaste.pl/ybf
Answer by Bunny83 · Feb 12, 2011 at 09:21 PM
Your problem is that Input.GetAxis("Mouse ScrollWheel") also returns delta movement just like Input.GetAxis("Mouse X").
You use the value as a event when it's greater or lower than "0". That means you don't need to multiply your speed with deltaTime. If you scroll one time upwards Input.GetAxis("Mouse ScrollWheel") will return a value greater that 0 for one frame. In the next frame it will be zero again. If your FPS is high, deltaTime will be very low.
In Webplayer the FPS is limited to 60fps by default, that's why it's faster than in standalone where you probably have more FPS.
distance += scrollspeed;
and
distance -= scrollspeed;
Answer by Galad · Feb 12, 2011 at 10:17 PM
Thanks a lot man! I will take a closer look at it still today. That doesnt explain proper behavious in Unity "play mode" however... but still it's much more than i was able to find.
Your answer
Follow this Question
Related Questions
Full scene speed-based motion blur 2 Answers
Move the camera to the left when the mousecursor is left 1 Answer
Stop Motion Camera Effect 0 Answers