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

Beginner Learning C# with Unity and Need Help with an Error

Discussion in 'Scripting' started by J534, Oct 19, 2017.

  1. J534

    J534

    Joined:
    Oct 19, 2017
    Posts:
    9
    Hi everyone,

    I'm sure if I knew a little bit about C# the error would be obvious but I'm wracking my brain trying to figure out why I'm getting an error. I'm following along right now with the book Unity in Action and trying to attach a script that allows the player to look around. Here's my source code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class MouseLook : MonoBehaviour {
    6.     public enum RotationAxes {
    7.         MouseXAndY = 0,
    8.         MouseX = 1,
    9.         MouseY = 2
    10.     }
    11.     public RotationAxes axes = RotationAxes.MouseXAndY;
    12.  
    13.     // Update is called once per frame
    14.     void Update () {
    15.         if (axes == RotaionAxes.MouseX) {
    16.             //horizontal rotation code
    17.         }
    18.         else if (axes == RotationAxes.MouseY) {
    19.             //vertical rotation code
    20.         }
    21.         else {
    22.             //both horizontal and vertical rotation
    23.         }
    24.     }
    25. }
    26.  
    When I try to attach the code the console returns: Assets/MouseLook.cs(15,15): error CS0103: The name `RotaionAxes' does not exist in the current context

    If anyone can help me figure out where my mistake is that would be great help! Thanks!
     
  2. J534

    J534

    Joined:
    Oct 19, 2017
    Posts:
    9
    Nevermind... Nevermind!!!.... I forgot a 't' in Rotational! o_O