Search Unity

Problems with Create with Code Lesson 3.3 Don't Just Stand There Error CS0246

Discussion in 'Community Learning & Teaching' started by Ufreewoody, Jan 12, 2020.

  1. Ufreewoody

    Ufreewoody

    Joined:
    Nov 3, 2017
    Posts:
    16
    I am still having problems with my code. I am getting this CS0246 Error

    error CS0246: The type or namespace name `_Other_' Could not be found.
    Are you missing a using directive of assembly reference?

    I am a Newbie but I wanna do things right, so here is my code with Code Tags

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerController : MonoBehaviour
    6. {
    7.     private Rigidbody playerRb;
    8.     private Animator playerAnim;
    9.     public float jumpForce = 10;
    10.     public float gravityModifier;
    11.     public bool isOnGround = true;
    12.     public bool gameOver = false;
    13.  
    14.     // Start is called before the first frame update
    15.     void Start()
    16.     {
    17.         playerRb = GetComponent<Rigidbody>();
    18.         playerAnim = GetComponent<Animator>();
    19.         Physics.gravity *= gravityModifier;
    20.     }
    21.  
    22.     // Update is called once per frame
    23.     void Update()
    24.     {
    25.         if (Input.GetKeyDown(KeyCode.Space) && isOnGround)
    26.         {
    27.             playerRb.AddForce(Vector3.up * 10 * jumpForce, ForceMode.Impulse);
    28.             isOnGround = false;
    29.             playerAnim.SetTrigger("Jump_trig");
    30.             {
    31.  
    32.             }
    33.         }
    34.     }
    35.     // here is the first new reference to "other" this is where I am not sure how
    36.     // to fix this since it appears that the reference is invalid how do I fix this?
    37.  
    38.         private void OnCollisionEnter(Collision collision other)
    39.     {
    40.             if (other.gameObject.CompareTag("Ground"))
    41.         {
    42.             isOnGround = true;
    43.         }   else if (other.gameObject.CompareTag("Obstacle"))
    44.         {
    45.             Debug.Log("Game Over Woody");
    46.             gameOver = true;
    47.             playerAnim.SetBool("Death_b", true);
    48.             playerAnim.SetInteger("DeathType_int", 1);
    49.         }
    50.     }
    51. }
     
  2. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
    There is a mistake in Part 6 of this lesson (Set up a falling animation), where this code appears, hence your confusion.
    upload_2020-1-12_18-24-1.png
     
  3. Ufreewoody

    Ufreewoody

    Joined:
    Nov 3, 2017
    Posts:
    16
    Thank you so very much, I will just ignore and move on.