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 moshinko · Mar 01, 2015 at 12:11 AM · scriptingproblem

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.

Comment
Add comment · Show 1
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
avatar image AlwaysSunny · Feb 28, 2015 at 04:27 AM 2
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Share
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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

problem with the jump code.. 1 Answer

Do asleep rigidbodies prevent from modifying its variables in runtime? 1 Answer

Scripts Won't Update? 0 Answers

How to watch variables from another script efficiently? 1 Answer

Acces SceneView Settings programmatically 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