- Home /
Script Error with CharacterMotor
i have been writing a swimming script and i have run into an error which states:
Assets/Standard Assets/Scripts/Swimmer.cs(6,9): error CSO246: The type or namespace name 'CharactorMotor' could not be found. Are you missing a using directive or an assembly reference?
and here is my script so far:
using UnityEngine; using System.Collections;
public class Swimmer : MonoBehaviour { public CharacterController cc; public CharacterMotor cm; void Start () { RenderSettings.fog = false; RenderSettings.fogColor = new Color (0.2f, 0.4f, 0.8f, 0.5f); RenderSettings.fogDensity = 0.04f;
cc = gameObject.GetComponent<CharacterController> ();
cm = gameObject.GetComponent<CharacterMotor> ();
}
bool IsUnderwater()
{
return gameObject.transform.position.y < 0;
}
void Update () {
RenderSettings.fog = IsUnderwater ();
if (IsUnderwater ()) {
cm.movement.maxForwardSpeed = 2;
cm.movement.maxSidewaysSpeed = 2;
cm.movement.maxBackwardsSpeed = 2;
cm.movement.maxFallSpeed = 2;
if (Input.GetKey(KeyCode.LeftShift))
cm.SetVelocity(new Vector3(cc.velocity.x, 3,cc.velocity.z));
}
else
{
cm.movement.maxForwardSpeed = 12;
cm.movement.maxSidewaysSpeed = 9;
cm.movement.maxBackwardsSpeed = 9;
cm.movement.maxFallSpeed = 20;
}
}
}
I have the charactermotor script within my project, and equiped with my chracter, for i am using the default fps controller.
Please respond with an answer because Im unsure of what to do.
P.S. the swimming script is Cscript and the CharacterMotor script is javascript if that helps in anyway.
The problem is the type discrepancy. I'd highly recommend converting the unityscript script to C#. This is VERY easy to do 99% of the time. Save yourself some headaches: just don't futz with multiple script types. In fact, don't futz with .js, period.
You CAN mix-and-match script types in the same project by placing them in particular folders in your asset hierarchy, but this is so incredibly messy, I'd strongly advise against it.
Answer by moshinko · Mar 03, 2015 at 12:30 AM
i found out the problem, i was trying to put the script i wrote in the standard assets script folder, so instead i made a script folder on the root of the assets and put the script in there, now it works fine, thanks for the link though. I'll be sure to use it for future references.