Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by CyberArtist · Sep 07, 2014 at 04:28 AM · c#third-person

C# Third Person Controller CS1061

Following a tutorial on creating a third person controller and I'm stuck on this error:

"Assets/Scripts/Character/PlayerMotor.cs(91,40): error CS1061: Type PlayerCamera' does not contain a definition for CameraState' and no extension method CameraState' of type PlayerCamera' could be found (are you missing a using directive or an assembly reference?)"

I'm following the exact scripting for the problem area and I don't know why I have this error.

Script where the error is located:

 using UnityEngine;
 using System.Collections;
 
 using Helper;
 
 /// <summary>
 /// This script is included with the PlayerCharacter script includes & governs the behaviors of this instance's
 /// ability to move around the enviornment and animate it's model based on human input.
 /// </summary>
 
 public class PlayerMotor : MonoBehaviour 
 {
 
 #region Public Fields & Properties
 
     public float walkSpeed = 3f;
     public float runSpeed = 5f;
     public float sprintSpeed = 7f;
     private float _rotationSpeed = 140f;
     public float jumpHeight = 10f;
     public float gravity = 20f;
 
 #endregion
 
 #region Private Fields & Properties
 
     private float _horizontal = 0f;
     private float _vertical = 0f;
 
     private float _moveSpeed;
 
     private float _airVelocity = 0f;
 
     private Transform _myXform;
 
     private Vector3 _moveDirection = Vector3.zero;
 
     private CharacterController _controller;
 
     private Animator _animator;
 
     private SpeedState _speedState = SpeedState.Run;
     private CameraState _cameraState;
 
     private PlayerCharacter _pc;
     private PlayerCamera _camera;
 
 #endregion
 
 #region Getters & Setters
 
     ///<summary>
     /// Gets or sets the move speed.
     /// </summary>
     /// <value>
     /// The move speed
     /// </value>
     public float MoveSpeed
     {
         get{return _moveSpeed;}
         set{_moveSpeed = value;}
     }
 
 #endregion
 
 #region System Methods
     
     // Use this for initialization
     private void Start () 
     {
         if(networkView.isMine || Network.peerType == NetworkPeerType.Disconnected)
         {
             //Chache references to child components of this gameObject.
             _myXform = this.GetComponent<Transform>();
 
             _pc = this.GetComponent<PlayerCharacter>();
             _camera = this.GetComponent<PlayerCamera>();
 
             _animator = _pc.Animator;
             _controller = _pc.Controller;
         }
         else
         {
             enabled = false;
         }
     }
     
     // Update is called once per frame
     private void Update () 
     {
         _cameraState = _camera.CameraState;
 
         switch(_cameraState)
         {
             case CameraState.Normal:
 
             //Allow the player to rotate their character.
             if(Input.GetAxis(PlayerInput.Horizontal) > 0.1f || Input.GetAxis(PlayerInput.Horizontal) < -0.1f)
             {
                 _myXform.Rotate(0f, Input.GetAxis(PlayerInput.Horizontal) * _rotationSpeed * Time.deltaTime, 0f);
             }
 
             break;
 
             case CameraState.Target:
 
 
 
             break;
         }
     }
 
 #endregion
 
 #region Custom Methods
 
     private void CalculateSpeed()
     {
         switch(_speedState)
         {
             case SpeedState.Walk:
 
             _moveSpeed = walkSpeed;
 
             break;
 
             case SpeedState.Run:
 
             _moveSpeed = runSpeed;
 
             break;
 
             case SpeedState.Sprint:
 
             _moveSpeed = sprintSpeed;
 
             break;
         }
     }
 
 #endregion
 }


Helper Script:

 enter code hereusing UnityEngine;
 using System.Collections;
 
 namespace Helper
 {
 
 #region Reference Cache
 
     public class PlayerInput
     {
         public static string Horizontal = "Horizontal";
         public static string Vertical = "Vertical";
 
         public static string Jump = "Jump";
     }
 
     public class GameTag
     {
         // System Tags
         public static string Untagged = "Untagged";
         public static string Respawn = "Respawn";
         public static string Finish = "Finish";
         public static string EditorOnly = "EditorOnly";
         public static string MainCamera = "MainCamera";
         public static string Player = "Player";
         public static string GameController = "GameController";
 
         public static string PlayerCamera = "PlayerCamera";
     }
 
     public class Resource
     {
         public static string AnimatorController = "System/PlayerAnimator";
     }
 
     public static class AnimatorConditions
     {
         public static string Speed = "Speed";
         public static string Direction = "Direction";
         public static string Grounded = "Grounded";
         public static string AirVelocity = "AirVelocity";
     }
 
 #endregion
 
 #region FSN Numerations
 
     public enum CameraState
     {
         Normal,
         Target
 
     }
 
     public enum SpeedState
     {
         Walk,
         Run,
         Sprint
     }
 
     
 #endregion
 
 #region Object Structures
 
     public struct CameraTargetObject
     {
         private Vector3 position;
 
         private Transform xForm;
 
         public Vector3 Position
         {
             get{return position;}
             set{position = value;}
         }
 
         public Transform XForm
         {
             get{return xForm;}
             set{xForm = value;}
         }
 
         public void Init(string camName, Vector3 pos, Transform transform, Transform parent)
         {
             position = pos;
             xForm = transform;
             xForm.name = camName;
             xForm.parent = parent;
             xForm.localPosition = Vector3.zero;
             xForm.localPosition = position;
         }
     }
 
     public struct CameraMountPoint
     {
         private Vector3 position;
         
         private Transform xForm;
         
         public Vector3 Position
         {
             get{return position;}
             set{position = value;}
         }
         
         public Transform XForm
         {
             get{return xForm;}
             set{xForm = value;}
         }
         
         public void Init(string camName, Vector3 pos, Transform transform, Transform parent)
         {
             position = pos;
             xForm = transform;
             xForm.name = camName;
             xForm.parent = parent;
             xForm.localPosition = Vector3.zero;
             xForm.localPosition = position;
         }
     }
 
 
 
 #endregion
 
 }



Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How do I "trickle" a function's effect over n seconds? 2 Answers

NullReferenceException: Object reference not set to an instance of an object 1 Answer

AI help (C) 0 Answers

Using the "ThirdPersonController" Script without its Camera? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges