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. Dismiss Notice

i have many error please help me

Discussion in 'Scripting' started by GoldenMine12, Oct 24, 2020.

  1. GoldenMine12

    GoldenMine12

    Joined:
    Oct 22, 2020
    Posts:
    38
    i have 2 errors:

    Assets\RagdollDeath.cs(8,6): error CS0246: The type or namespace name 'SerializedFieldAttribute' could not be found (are you missing a using directive or an assembly reference?)


    Assets\RagdollDeath.cs(8,6): error CS0246: The type or namespace name 'SerializedField' could not be found (are you missing a using directive or an assembly reference?)

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class RagdollDeath : MonoBehaviour
    7. {
    8.     [Header("References")]
    9.     [SerializedField] private Animator animator = null;
    10.  
    11.     private Rigidbody[] ragdollBodies;
    12.     private Collider[] ragdollColloders;
    13.  
    14.     private void Start()
    15.     {
    16.         ragdollBodies = GetComponentsInChildren<Rigidbody>();
    17.         ragdollColliders = GetComponentsInChildren<Collider>();
    18.  
    19.         ToggleRagdoll(False);
    20.  
    21.         Invoke(nameof(Die), 5f);
    22.     }
    23.  
    24.     private void Die()
    25.     {
    26.         ToggleRagdoll(true);
    27.  
    28.         foreach(Rigidbody rb in ragdollBodies)
    29.         {
    30.             rb.AddExplosionForce(107f, new Vector3(-1f, 0.5f, -1f), 5f, 0f, ForceMode.Impulse);
    31.         }
    32.     }
    33.  
    34.     private void ToggleRagdoll(bool state)
    35.     {
    36.         animator.enabled = !state;
    37.  
    38.         foreach(Rigidbody rb in ragdollBodies)
    39.         {
    40.             rb.isKinematic = !state;
    41.         }
    42.  
    43.         foreach (Collider collider in ragdollColliders)
    44.         {
    45.             collider.enabled = state;
    46.         }
    47.     }
    48.  
    49.  
    50. }
    51.  
    52. [code]
     
  2. Stevens-R-Miller

    Stevens-R-Miller

    Joined:
    Oct 20, 2017
    Posts:
    664
    [SerializedField]
    should be
    [SerializeField]
     
  3. GoldenMine12

    GoldenMine12

    Joined:
    Oct 22, 2020
    Posts:
    38
    i fixed it and i got 6 new errors and something else the last 2 lines:

    Assets\animationStateController.cs(37,14): error CS0103: The name 'isrunning' does not exist in the current context

    Assets\animationStateController.cs(42,13): error CS0103: The name 'isrunning' does not exist in the current context

    Assets\RagdollDeath.cs(16,9): error CS0103: The name 'ragdollColliders' does not exist in the current context

    Assets\RagdollDeath.cs(18,23): error CS0103: The name 'False' does not exist in the current context

    Assets\RagdollDeath.cs(42,39): error CS0103: The name 'ragdollColliders' does not exist in the current context

    Assets\scripts\controller\Movement.cs(52,12): error CS0103: The name 'collisionn' does not exist in the current context

    Assets\Nokobot\Modern Guns - Handgun\_Demo Assets\SimpleShoot.cs(16,40): warning CS0649: Field 'SimpleShoot.casingExitLocation' is never assigned to, and will always have its default value null
     
  4. Stevens-R-Miller

    Stevens-R-Miller

    Joined:
    Oct 20, 2017
    Posts:
    664
    Those error messages are telling you what's wrong. For example, this one:
    tells you there is no such identifier as "ragdollColliders" in your class or method. You probably think there is, because (most likely) you meant to type "ragdollColliders" when you typed this line:

    private Collider[] ragdollColloders;


    See the difference?

    Same with "False." You probably meant "false."

    A lot of us are happy to help, but you need to put your own effort in as well. Look at the error messages and check your typing.
     
  5. GoldenMine12

    GoldenMine12

    Joined:
    Oct 22, 2020
    Posts:
    38
    i will i am just new to unity and c sharp, i fixed most of the errors except for 1:

    Assets\animationStateController.cs(42,13): error CS0149: Method name expected
     
  6. Stevens-R-Miller

    Stevens-R-Miller

    Joined:
    Oct 20, 2017
    Posts:
    664
    You'll have to post the code for animationStateController. (Note: it is very common practice to give your classes names that start with a capital letter, like "AnimationStateController.")
     
  7. GoldenMine12

    GoldenMine12

    Joined:
    Oct 22, 2020
    Posts:
    38
    here is the code:

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class animationStateController : MonoBehaviour
    7. {
    8.     Animator animator;
    9.     int isWalkingHash;
    10.     int isRunningHash;
    11.  
    12.     // Start is called before the first frame update
    13.     void Start()
    14.     {
    15.         animator = GetComponent<Animator>();
    16.         isWalkingHash = Animator.StringToHash("isWalking");
    17.         isRunningHash = Animator.StringToHash("isRunning");
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update()
    22.     {
    23.         bool isRunning = animator.GetBool(isRunningHash);
    24.         bool isWalking = animator.GetBool(isWalkingHash);
    25.         bool forwardPressed = Input.GetKey("w");
    26.         bool runPressed = Input.GetKey("left shift");
    27.  
    28.         if (!isWalking && forwardPressed)
    29.         {
    30.             animator.SetBool(isWalkingHash, true);
    31.         }
    32.  
    33.         if (isWalking && !forwardPressed)
    34.         {
    35.             animator.SetBool(isWalkingHash, false);
    36.         }
    37.  
    38.         if (!isRunning && (forwardPressed && runPressed))
    39.         {
    40.             animator.SetBool(isRunningHash, true);
    41.         }
    42.  
    43.         if (isRunning(!forwardPressed || !runPressed))
    44.         {
    45.             animator.SetBool(isRunningHash, false);
    46.         }
    47.     }
    48. }
    49.  
    50. [code]
     
  8. GoldenMine12

    GoldenMine12

    Joined:
    Oct 22, 2020
    Posts:
    38
    now the thing is i cant see what is wrong in the code, i went to the spot it says the error is at but i dont see anything wrong
     
  9. Stevens-R-Miller

    Stevens-R-Miller

    Joined:
    Oct 20, 2017
    Posts:
    664
    In this line:

    if (!isRunning && (forwardPressed && runPressed))


    you are using
    isRunning
    as a boolean variable.

    The problem is in this line:

    if (isRunning(!forwardPressed || !runPressed))


    What is different in that line about how you are using
    isRunning
    ? You are getting a good clue in the error message, "Method name expected."
     
  10. GoldenMine12

    GoldenMine12

    Joined:
    Oct 22, 2020
    Posts:
    38
    i fixed it thank so much
     
  11. Vik-Thor

    Vik-Thor

    Joined:
    Jun 11, 2018
    Posts:
    3
    Me it's about this script.

    // Cinema Suite
    using UnityEngine;

    namespace CinemaDirector
    {
    /// <summary>
    /// Event that captures a screenshot when triggered.
    /// </summary>
    [CutsceneItem("Utility", "Storyboard", CutsceneItemGenre.GlobalItem)]
    public class StoryboardEvent : CinemaGlobalEvent
    {
    public string FolderName = "Storyboard";
    public static int Count = 0; // Count how many screenshots have been captured.

    /// <summary>
    /// Capture screenshot on trigger.
    /// </summary>
    public override void Trigger()
    {
    ScreenCapture.CaptureScreenshot(string.Format(@"Assets\{0}{1}.png", this.gameObject.name, Count++));
    }
    }
    }

    But Assets/Cinema Suite/Cinema Director/Cutscene Items/Global Items/Utility/StoryboardEvent.cs(20,13): error CS0103: The name `ScreenCapture' does not exist in the current context.

    What should Do I?
     
  12. Vik-Thor

    Vik-Thor

    Joined:
    Jun 11, 2018
    Posts:
    3
    What should do I?
     

    Attached Files:

  13. bobisgod234

    bobisgod234

    Joined:
    Nov 15, 2016
    Posts:
    1,042
    You should not hijack someones old thread, and instead start your own thread.
     
    Stevens-R-Miller likes this.
  14. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
    As The Godlike Bob pointed out, hijacking threads is against forum rules.

    Make your own thread. It's free. When you do, here is how to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    How to understand errors in general:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/
     
    Stevens-R-Miller likes this.