I was making a system to climb the level difference.
When I try to get component from a script,
c:\Users\user\Documents\New Unity Project 3\Asset\StandardAsets\Characters\ThirdPersonCharacter\Scripts\ThirdPersonCharacter.cs(4,4): Error CS0246: type or namespace name 'dansacollider1' was not found, insufficient using directives or assembly references. (CS0246) (Assembly-CSharp-firstpass)
appears with a build error.
·Structure
·Thirdpersoncontroller
·Model
·dansacolloder1
·dansacolloder2
·dansacolloder3
·dansacolloder4
·dansacolloder5
·Script
·thirdpersoncontroller.cs
using UnityEngine;
using System.Collections;
namespace UnityStandardAssets.Characters.ThirdPerson
{
RequireComponent (type of (Rigidbody))]
RequireComponent (type of (CapsuleCollider))
RequireComponent (type of (Animator))
public class ThirdPersonCharacter: MonoBehavior
{
SerializeField floatm_MovingTurnSpeed=360;
[SerializeField] floatm_StationaryTurnSpeed = 180;
SerializeField floatm_JumpPower=12f;
Range(1f, 4f) SerializeField floatm_GravityMultiplier=2f;
[SerializeField] floatm_RunCycleLegOffset=0.2f; // specific to the character in sample assemblies, will need to be modified to work with others
SerializeField floatm_MoveSpeedMultiplier=1f;
SerializeField floatm_AnimSpeedMultiplier=1f;
SerializeField floatm_GroundCheckDistance=0.1f;
Rigidbody m_Rigidbody;
Animator m_Animator;
booolm_IsGrounded;
floatm_OrigGroundCheckDistance;
const float_Half = 0.5f;
floatm_TurnAmount;
floatm_ForwardAmount;
Vector 3m_GroundNormal;
floatm_CapsuleHeight;
Vector 3m_CapsuleCenter;
CapsuleColliderm_Capsule;
booolm_Crouching;
// Level difference system
pool dansatrigger=false;
pool dc1 = false;
pool dc2 = false;
pool dc3 = false;
pool dc4 = false;
pool dc5 = false;
void Start()
{
m_Animator=GetComponent<Animator>();
m_Rigidbody=GetComponent<Rigidbody>();
m_Capsule=GetComponent<CapsuleCollider>();
m_CapsuleHeight=m_Capsule.height;
m_CapsuleCenter=m_Capsule.center;
m_Rigidbody.constraints=RigidbodyConstraints.FreezeRotationX |RigidbodyConstraints.FreezeRotationY |RigidbodyConstraints.FreezeRotationZ;
m_OrigGroundCheckDistance=m_GroundCheckDistance;
// Level difference system
}
public void update()
{
// Level difference system
varf_dc1 = GameObject.Find("dansacollider1");
dansacollider1g_dc1 = f_dc1.GetComponent<dansacollider1>();
g_dc1.dansatrigger1 = dc1;
varf_dc2 = GameObject.Find("dansacollider2");
dansacollider1g_dc2 = f_dc2.GetComponent<dansacollider2>();
g_dc2.dansatrigger2 = dc2;
varf_dc3 = GameObject.Find("dansacollider3");
dansacollider3g_dc3 = f_dc3.GetComponent<dansacollider3>();
g_dc3.dansatrigger3 = dc3;
varf_dc4 = GameObject.Find("dansacollider4");
dansacollider4g_dc4 = f_dc4.GetComponent<dansacollider4>();
g_dc4.dansatrigger4 = dc4;
varf_dc5 = GameObject.Find("dansacollider5");
dansacollider 5g_dc5 = f_dc5.GetComponent<dansacollider5>();
g_dc5.dansatrigger5 = dc5;
if(dc1){
// Level 1 treatment
m_Animator.SetFloat("dansaheight", 1);
dansatrigger = true;
if(dc2){
// Level 2 treatment
m_Animator.SetFloat("dansaheight", 2);
dansatrigger = true;
if(dc3){
// Level 3 treatment
m_Animator.SetFloat("dansaheight", 3);
dansatrigger = true;
if(dc4){
// Level 4 treatment
m_Animator.SetFloat("dansaheight", 4);
dansatrigger = true;
if(dc5){
// Level 5 treatment
m_Animator.SetFloat("dansaheight", 5);
dansatrigger = true;
}
}
}
}
}
else{
dansatrigger = false;
}
}
·dansacollider 1-5
using UnityEngine;
using System.Collections;
public class dansacollider1: MonoBehavior {
public pool dansatrigger1;
// Use this for initialization
public void Start() {
dansatrigger1 = false;
}
// be called at the moment of collision
public void OnTriggerEnter (Collider other) {
if(other.gameObject.tag=="dansa"){
dansatrigger1 = true;
}
}
// be called at the moment away from a collision
public void OnTriggerExit (Collider other) {
if(other.gameObject.tag=="dansa"){
dansatrigger1 = false;
}
}
// Update is called once per frame
void Update() {
}
}
Unity intra-project scripts are compiled in different order depending on the specific folder.
The compilation order can be found in the Unity documentation at the link below.
http://docs.unity3d.com/ja/current/Manual/ScriptCompileOrderFolders.html
If you look at the questions, you can see that ThirdPersonCharacter.cs is included in the Standard Assets folder.
Because the Standard Assets folder is compiled early, you cannot browse scripts outside the Standard Assets folder.
I don't know which folder dansacollider1.cs is in, but I think it is in a folder outside the Standard Assets folder.
Please check it out.
© 2024 OneMinuteCode. All rights reserved.