Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

ladder test game - sluggish mouse movement

Discussion in 'Scripting' started by ron, Oct 8, 2008.

  1. ron

    ron

    Joined:
    Dec 21, 2007
    Posts:
    35
    I have implemented a small test game where an FPS player can climb a ladder. I wrote an FPS controller script which allows the player to climb the ladder. The ladder consists of a two box colliders: one is located at the top of the ladder and located at the bottom of the ladder. When the player collides with either of these box-colliders it climbs onto the ladder. When player is on the ladder and hits the top or bottom collider it climbs off the ladder. That works fine.

    The main camera attached to the player is controller by the standard MouseLook script. When I test the game in the "Game" window everything appears to be ok. When I build the game either as MacOS or Windows stand alone application the movement of the main camera is very sluggish.

    I attached the Mac OS X Intel standalone version of the game.

    Has anyone come across a similar problem before? Could you please point me in the right direction?

    PS If you want to quit the game press the Esc button
     

    Attached Files:

  2. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    The camera didn't seem sluggish to me, but there was a slight but perceptible jitter. Just a hunch, but maybe try using FixedUpdate() to change the camera position so it gets updated faster than the framerate? I seem to remember coming across a similar thread recently.

    It's rather slick how you climb and descend the ladder. However, it took a bit to get used to changing the control I used when going down the contraption after you spun about.
     
  3. ron

    ron

    Joined:
    Dec 21, 2007
    Posts:
    35
    Quietus, thanks for your comments.

    I'm using the standard MouseLook script which implements FixedUpdate.

    Not really sure what's going on. Do you think the script length (the FPSController script is quite large) can have an effect on performance?
     
  4. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    I seriously doubt that, Ron.

    It's also somewhat difficult to perceive whether it's really the camera or the geometry that's causing the jitters in the app you uploaded. Being new to Unity myself, I'm unsure as to what profiling capabilities exist that could assist you in making that determination.

    You also mentioned that it was 'sluggish.' I'm running it on a 2008 MBP, could be why I just get jitters and not sluggish response.

    Here is the link to the thread I referenced before. Seems he had a similar issue to yours. It states that the trick is to always update the mouse-look camera using the same form of update function you're moving your object around. Maybe it can provide the answer for you.

    Sorry I can't assist you further, but I'm sure someone will come along with an idea. Community seems really helpful around these parts.
     
  5. Sommer

    Sommer

    Joined:
    Oct 8, 2008
    Posts:
    12
    You could try using LateUpdate() instead of Update() for your camera code. In that way you make sure that the camera doesnt get updated before all the other things are done updating, which has worked for me in another situation. I cant promise you that it solves your problem, but it would be a very easy thing to try out.
     
  6. ron

    ron

    Joined:
    Dec 21, 2007
    Posts:
    35
    Sommer, using LateUpdate in the MouseLook script has actually made quite a difference. Thanks!
     
  7. ron

    ron

    Joined:
    Dec 21, 2007
    Posts:
    35
    I think I found the reason why my mouse movement seemed sluggish: I think the game struggles when trackpad/mousepad and a mouse are active at the same time. When I disable the trackpad/mousepad the mouse movement is smooth.
     
  8. Jasper-Hesseling

    Jasper-Hesseling

    Joined:
    Jul 27, 2009
    Posts:
    34
    Hi Ron, Is it possible to get the code you have created for the ladder climbing?

    Thanks
     
  9. podda999

    podda999

    Joined:
    Apr 26, 2010
    Posts:
    69
    I would also like to get my hands on that code if it is possible. Thanks Mate.