ETeeskiTutorials FPS1 Problem Diagnostic Collaboration Thread

Discussion in 'Teaching' started by eteeski, Mar 5, 2012.

  1. Zwero

    Zwero

    New Member

    Joined:
    Jun 26, 2012
    Messages:
    7
    Solved
    Last edited: Jun 26, 2012
  2. Zwero

    Zwero

    New Member

    Joined:
    Jun 26, 2012
    Messages:
    7
    Last edited: Jun 27, 2012
  3. PRASADNSG

    PRASADNSG

    New Member

    Joined:
    Jul 1, 2012
    Messages:
    1
    Need A Bit Debugging

    var walkAcc:float = 25.0;
    var cameraObject:GameObject;
    var maxWalkSpeed:float=20.0;
    var jumpVelocity:float=2000.0;
    @ HideInInspector
    var grounded:boolean=false;
    var maxSlope:float=60.0;
    @ HideInInspector
    var horizontalMovement:Vector2;
    function Update ()
    {

    horizontalMovement = Vector2(rigidbody.velocity.x,rigidbody.velocity.z);
    //Limit Speed
    if(horizontalMovement.magnitude > maxWalkSpeed)
    {
    horizontalMovement.Normalize();
    horizontalMovement *= maxWalkSpeed;
    }

    rigidbody.velocity.x=horizontalMovement.x;
    rigidbody.velocity.z=horizontalMovement.y;
    //Start Running
    transform.rotation=Quaternion.Euler(0,cameraObject.GetComponent(MouseLookScript).currentYRotation,0);
    rigidbody.AddRelativeForce(Input.GetAxis("Horizontal")*walkAcc,0,Input.GetAxis("Vertical")*walkAcc);
    //jump on Pressing space and if on grounded
    if (Input.GetButtonDown("Jump") &grounded)
    rigidbody.AddForce(0,jumpVelocity,0);
    }
    function OnCollisionEnter (collisionInfo : Collision)
    {
    for (var contact : ContactPoint in collisionInfo.Contacts)
    {
    if (Vector3.Angle(contact.normal, Vector3.up) < maxSlope)
    grounded = true;
    }
    }
    function OnCollisionExit ()
    {
    grounded = false;
    }
  4. AlexSR

    AlexSR

    New Member

    Joined:
    Jul 2, 2012
    Messages:
    2
    Hi, first i want to say that your tutorial is great!

    I'm on 1.8 and I noticed that when the player circulates a object (circling it with wasd and always looking for him) the object shakes a lot, it takes a lot of smoothness. I already downloaded the final project file of your tutorial and the same thing happens. You noticed that too? Any idea how to solve this?

    thank you
  5. eteeski

    eteeski

    Member

    Joined:
    Feb 2, 2010
    Messages:
    465
    Is it the floor that's shaking? I did notice that. It's because I scaled the floor up to like 1000000x1000000 if you scale it down to something reasonable, the shaking stops.
  6. AlexSR

    AlexSR

    New Member

    Joined:
    Jul 2, 2012
    Messages:
    2
    Is not the floor.

    In the video will not show up, but if you do the same movement you will see.
    Last edited: Jul 2, 2012
  7. RowleyBirkin

    RowleyBirkin

    New Member

    Joined:
    Jul 4, 2012
    Messages:
    9
    Hi eteeski,

    Great tutorials, really loving your unique style and teaching methods. I especially loved the one breaking down quaternions into layman's terms, although sadly I'm still getting my head around them! I'm sure the penny will drop sooner or later!

    Now to my question. I am in the process of modifying the mouse-look script to behave in the following way:

    While the mouse button is down enable mouse look (so the player can't change view unless the button is down). Now this bit is pretty simple, even for me. I just wrapped the following line inside an if statement. Well, it seems to work as expected anyway ;) .

    if (Input.GetButton("Fire1")){
    transform.rotation = Quaternion.Euler(currentXRotation, currentYRotation, 0);
    }

    Ok, now the tricky bit I just can't get my head around... How can I make it so that once the user lets go of the mouse button the camera will gradually ease to a stop based on how quickly the user was turning when letting the button go? Just to clarify, all I need the camera to do is rotate on the spot. There are no translations involved as the camera is locked to position 0,0,0.

    From my research into the available quaternion functions in the unity docs and from my uneducated point of view it seems that all of them expect you to be able to give the function a position that you eventually want the rotation to end at or point towards. I don't know the exact point that I'd like the camera to come to a rest as it is based on mouse velocity in X and Y which can change dynamically. I really hope I am over-complicating this issue (as oddly I tend to do with unity). Most problems I encounter end up being so much more straightforward than I could have imagined when planning how to execute them in the first place!

    Thanks so much for your time and keep up the incredible work. You are an inspiration to me.

    Rowley
    Last edited: Jul 4, 2012
  8. mainmatrix

    mainmatrix

    New Member

    Joined:
    Jul 3, 2012
    Messages:
    2
  9. GothicGhost

    GothicGhost

    New Member

    Joined:
    Jul 2, 2012
    Messages:
    1
    @GiORg1 how did you fix the the problem of when looking down and your character jumps/moves about like the gun is effecting the player ?

    Also another problem I have is in FPS1.23 Switching Guns the switch weapon command only works once?

    Thanks for any help guys/girls :)
    Last edited: Jul 8, 2012
  10. FlyingKuh

    FlyingKuh

    New Member

    Joined:
    Jul 9, 2012
    Messages:
    1
    Hi :) I set the player the to 12.5,3.5,0 . AND the gun to 13,3,1 . If i press play the gun transformes its position to 12.5,4.5,0 . What did i wrong? Sry fór my horrible english.
  11. NightoutCoder

    NightoutCoder

    New Member

    Joined:
    Jul 9, 2012
    Messages:
    5
  12. JoeCunningham

    JoeCunningham

    New Member

    Joined:
    Jul 16, 2012
    Messages:
    2
    Hey,


    I haven't made a thread, because this is just a small problem, but when I right click the gun only moves a tiny bit, and ends up nowhere near the middle of the screen. Any help would be appreciated. Thanks,


    Joe
  13. compugraphx

    compugraphx

    New Member

    Joined:
    Jul 2, 2012
    Messages:
    4
    Hi Eeteeski,

    First off, I can't thank you enough for your work on these tutorials. Total lifesaver!

    Episode: FPS 1.6

    Issue: I'm having an issue with the Mathf.SmoothDamp() function. I am receiving this error:
    I'm not sure why those variables are returning as not numbers, i've gone over the code several times to ensure there aren't any spelling errors or differences in variable values. I made sure all the variables in the inspector were the same as the video.

    My code in reference to error:
    Code (csharp):
    1.  
    2. var walkAccel:float = 100;             
    3. var walkAccelAirRatio:float = 0.1;     
    4. var walkDeAccel:float = 5;             
    5. var cameraObject:GameObject;           
    6. var maxWalkSpeed:float = 20;       
    7. @HideInInspector                       
    8. var walkDeAccelVolx:float;
    9. @HideInInspector
    10. var walkDeAccelVolz:float;
    11. var horizMovement:Vector2;             
    12. @HideInInspector
    13. var grounded:boolean = false;          
    14. var maxSlope:float = 60;               
    15. var jumpVelocity:float = 250;          
    16.  
    17. function Update () {
    18.  
    19. horizMovement = Vector2(rigidbody.velocity.x, rigidbody.velocity.z);
    20.    
    21.     if(horizMovement.magnitude > maxWalkSpeed){
    22.         horizMovement = horizMovement.normalized;
    23.         horizMovement *= maxWalkSpeed;
    24.     }
    25.  
    26. if(grounded){
    27.     rigidbody.velocity.x /= Mathf.SmoothDamp(rigidbody.velocity.x, 0, walkDeAccelVolx, walkDeAccel);
    28.     rigidbody.velocity.z /= Mathf.SmoothDamp(rigidbody.velocity.z, 0, walkDeAccelVolz, walkDeAccel);
    29. }  
    30. }
    31.  
    Link to my question thread: http://forum.unity3d.com/threads/144051-FPS-1.6-SmoothDamp.Angle-Error-with-NaN-amp-Infinity-results?p=985640#post985640
    Last edited: Jul 17, 2012
  14. venhip

    venhip

    New Member

    Joined:
    Jul 7, 2012
    Messages:
    5
    Last edited: Jul 20, 2012
  15. clownwiz1

    clownwiz1

    New Member

    Joined:
    Jul 20, 2012
    Messages:
    2
    Last edited: Aug 2, 2012
  16. aldian

    aldian

    New Member

    Joined:
    Jul 28, 2012
    Messages:
    25
    Last edited: Aug 2, 2012
  17. zipson1

    zipson1

    New Member

    Joined:
    Aug 11, 2012
    Messages:
    4
    FPS 1.26

    My gun is in the wrong place at the start of the game, but after reloading it moves to it's proper spot.

    A link to my thread Here.

    Thanks
    Last edited: Aug 11, 2012
  18. zipson1

    zipson1

    New Member

    Joined:
    Aug 11, 2012
    Messages:
    4
    I fixed this problem, but can't figure out how to get rid of the post... Sorry.
  19. mauro_rmp

    mauro_rmp

    New Member

    Joined:
    Aug 14, 2012
    Messages:
    1
    I have a problem with FPS 1.4 where we set a max walk speed. I followed the instructions and typed the new parts of the code exactly as you did. but in the end when I press play to test it out the console displays an error message that says

    MissingFieldException: Field 'UnityEngine.Vector2.z' not found.

    What went wrong? How do I fix this issue in order to continue. I would greatly appreciate it if you could reply to this message and help me
  20. eteeski

    eteeski

    Member

    Joined:
    Feb 2, 2010
    Messages:
    465
    maybe there's something wrong with my code, I'll look into it. I've been getting a lot of people with the same error. but vector2's dont have a Z only X and Y. either change the z to a y or change it to a vector3.
  21. KRAZEEnRECKLESS

    KRAZEEnRECKLESS

    New Member

    Joined:
    Aug 6, 2012
    Messages:
    1
    Its a quick question, so i did not make a thread.
    I have a sprinting code in my player move script that increases the acceleration and max speed.
    is there a way that i can rotate my gun object in the script when i sprint?
  22. SmileyFaceOfRom

    SmileyFaceOfRom

    New Member

    Joined:
    Aug 10, 2012
    Messages:
    6
    FPS 1.36 AI following issue

    Hello! I'm having an issue where the enemy won't follow my player from one cell to the next. As soon as I move from their cell or jump, they ignore me. When I land from jumping they come towards me, but when not in their cell they just ignore me.

    My personal thread here.
  23. eteeski

    eteeski

    Member

    Joined:
    Feb 2, 2010
    Messages:
    465
    animations would probably be the best way. or you could make the gun model a child of another child and change that local rotation depending on wether or not the player is sprinting.
  24. Marchello

    Marchello

    New Member

    Joined:
    Sep 9, 2012
    Messages:
    1
    I have problem after epizode 34... maybe somebody can resolve it...
    NullReferenceException: Object reference not set to an instance of an object
    Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator (System.String operatorName, System.Object lhs, System.Object rhs)
    EnemyMovementScript.Update () (at Assets/Script/EnemyMovementScript.js:23)

    Code (csharp):
    1. var currentCell : GameObject;
    2. var playerMovementScript : PlayerMovementScript;
    3. var playerCell : GameObject;
    4. var goalDoor : GameObject;
    5. var shortestPathSoFar :float;
    6. @HideInInspector
    7. var waitToStart : int = 5;
    8.  
    9. function Awake ()
    10. {
    11.     ShortestPathSoFar = Mathf.Infinity;
    12.     playerMovementScript = GameObject.FindWithTag("Player").GetComponent(PlayerMovementScript);
    13.     waitToStart = 5;
    14. }
    15.  
    16. function Update ()
    17. {
    18.     if (waitToStart <= 0)
    19.     {
    20.         playerCell = playerMovementScript.currentCell;
    21.         for (var doorCheckingNow : GameObject in currentCell.GetComponent(AICellScript).doors)
    22.         {
    23.             for (var i : int = 0; i <= doorCheckingNow.GetComponent(AIPathDoorScript).cells.lenght -1; i++)
    24.             {
    25.                 if (doorCheckingNow.GetComponent(AIPathDoorScript).cells[i] == playerCell)
    26.                 if (doorCheckingNow.GetComponent(AIPathDoorScript).doorsToCells[i] < shortestPathSoFar)
    27.                 {
    28.                     goalDoor = doorCheckingNow;
    29.                     shortestPathSoFar = doorCheckingNow.GetComponent(AIPathDoorScript).doorsToCells[i];
    30.                 }
    31.             }
    32.         }
    33.         shortestPathSoFar = Mathf.Infinity;
    34.     }
    35.     waitToStart -= 1;
    36. }
    37.  
    38. function OnTriggerStay (hitTrigger : Collider)
    39. {
    40.     if (hitTrigger.tag == "AIpathCell")
    41.         currentCell = hitTrigger.gameObject;
    42. }
    Last edited: Sep 9, 2012
  25. Vordas32

    Vordas32

    New Member

    Joined:
    Sep 9, 2012
    Messages:
    12
    Problem with 1.8 Basic Gun with Weight

    On my Gunscript everything works great but a gun do not have good smooth, its jitter. I tried to put the whole code in LateUpdate() and just targetXRotation, targetYRotation in LateUpdate() but gun still has the jitter. When I put targetXRotation, targetYRotation in LateUpdate() a gun have smaller jitter but it still have. Can anyone help on this problem? Master how to solve this? Is it up to my pc that is slow. Maybe is framerates? Please help the teacher. Btw. Your videos is great. I like that you go in so details.

    http://forum.unity3d.com/threads/15...8-Basic-Gun-with-Weight?p=1031108#post1031108
  26. jan2100

    jan2100

    New Member

    Joined:
    Jun 29, 2012
    Messages:
    15
  27. lenis0012

    lenis0012

    New Member

    Joined:
    Sep 16, 2012
    Messages:
    3
    i got a problem at episode FPS1.8
    when i try to move i cant move, and when i look around it blocks it, but when i look around the capsule location changes, the camera and gun stay on the same location all the time
    this only happends when i enable the gunscript
    also, the scene screen starts movinf once a start the game with the gunscript, even though i dont do anything, while he game is just stuck

    Thread: here

    iif you need to know the Move script, just say it, but its not special at all
    Last edited: Sep 16, 2012
  28. peladovii

    peladovii

    Member

    Joined:
    Nov 1, 2010
    Messages:
    9
    Anyone else getting jumps at half speed when close to a wall / box etc?
    keenanwoodall likes this.
  29. eteeski

    eteeski

    Member

    Joined:
    Feb 2, 2010
    Messages:
    465
    yeah, that's because of using a rigidbody for the player. one way to help with that is to add a physic material to the player that has no friction on it.
  30. kirra1000

    kirra1000

    New Member

    Joined:
    Sep 2, 2012
    Messages:
    3
    :x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:x
    OK IM REALLY ANGRY THAT I CAN'T GET THIS PROBLEM FIXED. I HAVE BEEN TRYING BY MY OWN FOR 2 WEEKS. THE 1.13 VID THERE IS NO BULLET HOLE AND WHEN IT MAKES THE BULLET IT'S MAKES A EMPTY GAME OBJECT. PLEASE HELP.
    :x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:x
  31. eteeski

    eteeski

    Member

    Joined:
    Feb 2, 2010
    Messages:
    465
    alright, calm down man. Is your bullet hole prefab set up correctly? when you drag and drop the prefab into the scene, is there a bullet hole?
  32. kirra1000

    kirra1000

    New Member

    Joined:
    Sep 2, 2012
    Messages:
    3
    'height' is not a member of 'UnityEngine.Collider'.

    why is height not a member of UnityEngine.Collider. Plz help:roll:
  33. kirra1000

    kirra1000

    New Member

    Joined:
    Sep 2, 2012
    Messages:
    3
    soz I put the big letters above. Its just everyday I would spend like 2 hours on trying to fix it but it was just a spelling error. lol. but now my game is all over the place. I Can't add scripts to objects, theres a weird height error and now my gun is not atached to my PlayerCapsule. I think I should just restart completely. I have now spent 4 weeks doing this and I really want to keep going but it just looks like a mess.

    PS Im lening all of this because Im a modeler and just want to start out making games.
  34. Kaha

    Kaha

    New Member

    Joined:
    Nov 12, 2012
    Messages:
    5
  35. unity_noobling1

    unity_noobling1

    Member

    Joined:
    Nov 21, 2012
    Messages:
    21
    HELP ME PLEASE
    hey eteeski great tutorials
    im having problem with FPS1 1.33 i copied your code and fixed the error you had with the AIpathCellcScript for (var checkDoor : GameObject in cells.GetComponent(AIpathCellcScript).doors)

    this is the line where im also geting problems. it says Assets/AI Stuff/AIpathDoorScript.js(41,65): BCE0019: 'GetComponent' is not a member of 'Object'.

    PLEASE HELP ME

    ps sorry i didnt make a new thread im new to unity and dont know what im doing
    also you could start making tutorials all about what people want to learn about because your tutorials are so easy to follow
    YOUR THE BEST AND HOPE YOU CAN FIX MY PROBLEM :)
    Please Help
    Last edited: Nov 22, 2012
  36. mimishak

    mimishak

    New Member

    Joined:
    Dec 2, 2012
    Messages:
    9
    FPS1 1.4

    Please help me with this error. I did the exact things as mentioned.

    Assets/PlayerMovementScript.js(16,35): BCE0051: Operator '*' cannot be used with a left hand side of type 'System.Type' and a right hand side of type 'float'.
  37. eteeski

    eteeski

    Member

    Joined:
    Feb 2, 2010
    Messages:
    465
    if there's a #pragma strict in your code, delete it. make sure all your variables are of the right type, like float or int or vector3...
  38. aldian

    aldian

    New Member

    Joined:
    Jul 28, 2012
    Messages:
    25
    FPS 1.2 to 1.7

    Cant move player, restarted project and imported everything in but still cant get him to budge or jump.
  39. eteeski

    eteeski

    Member

    Joined:
    Feb 2, 2010
    Messages:
    465
    that's probably because the project zip file was made in unity 3.5, ill try to update that soon.
  40. Bruno999

    Bruno999

    New Member

    Joined:
    Dec 18, 2012
    Messages:
    1
    Hey men, i got a problem. My character doesn´t move, the script is right i think but there is an error:

    "Object reference not set to an instance of an object".

    I dont know how to fix it, so i need your help, please. Thanks.

    The script:

    var walkAcceleration : float = 5;
    var cameraObject : GameObject;

    function Update ()
    {
    transform.rotation = Quaternion.Euler(0, cameraObject.GetComponent(MouseLookScript).currentyRotation, 0);
    rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * walkAcceleration, 0, Input.GetAxis("Vertical") * walkAcceleration);
    }
  41. eteeski

    eteeski

    Member

    Joined:
    Feb 2, 2010
    Messages:
    465
    you probably didn't set up the camera object in the inspector.
  42. Sandr0G

    Sandr0G

    New Member

    Joined:
    Jul 15, 2012
    Messages:
    5
    Edit: Not 1.3, but 1.13. (In the title).

    First of all, thank you so much for doing these tutorials :D

    Ok, so, I have a few problems that I have been trying to fix on my own, I have fixed some but there are still two or three problems.

    The first problem is in BulletScript, here is the code:
    Code (csharp):
    1. var maxDist : float = 1000000000;
    2. var decalHitWall : GameObject;
    3. var floatInFrontOffWall : float = 0.00000001;
    4.  
    5. function Update ()
    6. {
    7.     var hit : RaycastHit;
    8.     if( Physics.Raycast( transform.position, transform.forward, hit, maxDist))
    9.     {
    10.         if( decalHitWall  hit.transform.tag == "Level Parts")
    11.             Instantiate( decalHitWall, hit.point + (hit.normal * floatInFrontOffWall), Quaternion.LookRotation(hit.normal));
    12.     }
    13.     Destroy(gameObject);
    14. }
    15.  
    16.  
    If I use Destroy(gameObject); the bullet holes don't show up, they aren't created at all.

    The other problem is that the bullet holes don't get deleted after X number of seconds, they just stay there for ever.
    DestroyAfterTimeScript code:
    Code (csharp):
    1. var destroyAfterTime : float = 5;
    2. var destroyAfterTimeRandomization : float = 2;
    3. @HideInInspector
    4. var countToTime : float;
    5.  
    6. function Awake ()
    7. {
    8.     destroyAfterTime += Random.value * destroyAfterTimeRandomization;
    9. }
    10.  
    11. function Update ()
    12. {
    13.     countToTime += Time.deltaTime;
    14.     if (countToTime >= destroyAfterTime)
    15.         Destroy(gameObject);
    16. }
    Please, I would really apreciate if you could help me.
    Thanks :)

    EDIT: I have fixed the problem myself. Thank you.
    Last edited: Dec 21, 2012
  43. galaboy

    galaboy

    Member

    Joined:
    Dec 2, 2012
    Messages:
    7
    Last edited: Dec 22, 2012
  44. unity_noobling1

    unity_noobling1

    Member

    Joined:
    Nov 21, 2012
    Messages:
    21
    there is two things you can do
    1 remove #strict thing
    make the collider a capsel collider
  45. unity_noobling1

    unity_noobling1

    Member

    Joined:
    Nov 21, 2012
    Messages:
    21


    i fixed it i removed the #strict thing
  46. Will_B

    Will_B

    New Member

    Joined:
    Dec 27, 2012
    Messages:
    23
    I'm having an issue with FPS 1.5 - Jumping.

    I can only jump if I remove ' grounded', however doing this means I can keep jumping in mid air.

    Here is my code, I've gone over it several times and cant see anything wrong with it:

    Code (csharp):
    1. var walkAcceleration : float = 5;
    2. var cameraObject : GameObject;
    3. var maxWalkSpeed : float = 20;
    4. @HideInInspector
    5. var horizontalMovement : Vector2;
    6.  
    7. var jumpVelocity : float = 20;
    8. @HideInInspector
    9. var grounded : boolean = false;
    10. @HideInInspector
    11. var maxSlope : float = 60;
    12.  
    13.  
    14. function Update ()
    15.  
    16. {
    17.     horizontalMovement =Vector2(rigidbody.velocity.x, rigidbody.velocity.z);
    18.     if (horizontalMovement.magnitude > maxWalkSpeed)
    19.     {
    20.         horizontalMovement = horizontalMovement.normalized;
    21.         horizontalMovement *= maxWalkSpeed;
    22.     }
    23.     rigidbody.velocity.x = horizontalMovement.x;
    24.     rigidbody.velocity.z = horizontalMovement.y;
    25.    
    26.     transform.rotation = Quaternion.Euler(0, cameraObject.GetComponent(MouseLookScript).currentYRotation, 0);
    27.     rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * walkAcceleration, 0, Input.GetAxis("Vertical") *walkAcceleration);
    28.    
    29.     if (Input.GetButtonDown("Jump") grounded)rigidbody.AddForce(0, jumpVelocity, 0);
    30. }
    31.  
    32. function onCollisionStay (collision : Collision)
    33. {
    34.     for (var contact : ContactPoint in collision.contacts)
    35.     {
    36.         if (Vector3.Angle(contact.normal, Vector3.up) < maxSlope)
    37.             grounded = true;
    38.     }
    39.    
    40. }
    41.  
    42. function OnCollisionExit ()
    43. {
    44.     grounded = false;
    45. }
    Any help would be appreciated

    Thanks
  47. Middleman3

    Middleman3

    New Member

    Joined:
    Jul 18, 2012
    Messages:
    1
    Tutorial 1.36 AI PathFinding.

    I'm not sure why, but my enemies are traveling to more than one randomized point in the cell before going to the door, even when the player is in a cell.
  48. galaboy

    galaboy

    Member

    Joined:
    Dec 2, 2012
    Messages:
    7
  49. B1ackSmoke93

    B1ackSmoke93

    New Member

    Joined:
    Dec 2, 2012
    Messages:
    4
    Last edited: Jan 8, 2013
  50. InhailedYeti

    InhailedYeti

    New Member

    Joined:
    Jan 9, 2013
    Messages:
    2
    Hey, your tutorials are really fantastic, thank you. I have a couple of errors in the scripts, however. One of them is major, and I have tried re-scripting 3 times to fix it. Here's what it looks like:
    [​IMG]

    And here is the script:
    Code (csharp):
    1. var cameraObject : GameObject;
    2. @HideInInspector
    3. var targetXRotation : float;
    4. @HideInInspector
    5. var targetYRotation : float;
    6. @HideInInspector
    7. var targetXRotationV : float;
    8. @HideInInspector
    9. var targetYRotationV : float;
    10.  
    11. var rotateSpeed : float = 0.3;
    12. var holdSide : float = - 0.5;
    13. var holdHeight : float = 0.5;
    14. var holdLength : float = 0.5;
    15.  
    16.  
    17. function Update () {
    18.     transform.position = cameraObject.transform.position + (Quaternion.Euler(targetXRotation, targetYRotation, 0) * Vector3(holdSide, holdHeight, holdLength));
    19.    
    20.     targetXRotation = Mathf.SmoothDamp( targetXRotation, cameraObject.GetComponent(MouseLook).xRotation, targetXRotationV, rotateSpeed);
    21.     targetYRotation = Mathf.SmoothDamp( targetYRotation, cameraObject.GetComponent(MouseLook).yRotation, targetYRotationV, rotateSpeed);
    22.  
    23.     transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 0);
    24. }
    My other bug, is I cannot move any direction but forward when crouched. Please help me, I've been stuck with this for so long trying so hard to fix it and I haven't been able to.