Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Crouch and Zoom

Discussion in 'Scripting' started by olliecard, Nov 19, 2007.

  1. olliecard

    olliecard

    Joined:
    Nov 6, 2007
    Posts:
    39
    Hello all,
    I am in the process of making a 2D/3D platform game, using the Unity engine. You play a prince going to save a prince, going over a variety of levels and so forth. Should be pretty good. All the levels are 3D, but the characters and props are actually just planes, so it looks like a diarama/shadow puppet style set. I am currently working on the character controller, and need some help with when the character crouches.
    Basically, I want the camera to zoom in on the character when you press "Crouch" (C button). I have used a Delta time based function to zoom in on the character, but it only zooms and, and snaps back to its original position. I am trying to get a nice smooth transistion between the two states. I tried using a forLoop, to little success. Any help would be appreciated in making this a smooth transistion.
    Cheers!
    Ollie

    Code (csharp):
    1. var smoothing = 10;
    2.  
    3. function FixedUpdate (){
    4.    
    5.     var smoother = Time.deltaTime / smoothing;
    6.  
    7.     if((movement.crouch)(SmoothFollowPrince.distance>=6)){
    8.    
    9.         SmoothFollowPrince.distance -= smoother;
    10. }
    11.  
    12.     if(movement.crouch==false){
    13.         SmoothFollowPrince.distance =8;
    14.  
    15.     }
    16. }
    17.  
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
  3. Neural Echo

    Neural Echo

    Joined:
    Jul 5, 2007
    Posts:
    83
    :eek: ... That's a very liberal minded twist!
     
  4. olliecard

    olliecard

    Joined:
    Nov 6, 2007
    Posts:
    39
    woops! a typo im afraid, our prince is infact saving a princess! although that would be a good plot twist. cheers for the help, will give it a go!