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 wyt3dr4g0n · Dec 13, 2013 at 08:52 PM · gravitymovement scriptswimming

Unity4 GetComponent(CharacterMotor) not working

Ok, I'm trying to create a simple script that detects my character's y against a set water level and turns off gravity when <=. I plan on expanding on it in the future, but right now my biggest hangup is just taking control of the built in CharacterMotor in the First Person Controller that comes with Unity. I've done a bit of research and know I'm supposed to be able to pull this in by using GetComponent(CharacterMotor). Only one problem though... where the hell is CharacterMotor?? Mono doesn't list it in the intellitype drop down, I instead see CharacterController, CharacterInfo, and CharacterJoint, but no CharacterMotor. If I forcefully enter this, I get BCE0005: Unknown identifier: 'CharacterMotor'. I see that it exists in Sources/Scripts under the Character Controller folder, and I even see it attached to the prefab I dragged onto my scene...

Here's my code, now admittedly it's BOO script, however I've tried the same thing in JS and I get the exact same problem, nothing can find CharacterMotor:

 import UnityEngine
 
 class Swim (MonoBehaviour):
     public waterlevel as double
     private character as GameObject
     def Start ():
         character = GameObject.Find("First Person Controller")
         chMotor = character.GetComponent(CharacterMotor)
     def Update ():
         if character.transform.position.y <= waterlevel:
             chMotor.Movement.Gravity = 0
         else:
             chMotor.Movement.Gravity = 20

What am I doing wrong here?

Comment
Add comment · Show 3
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 flaviusxvii · Dec 13, 2013 at 08:57 PM 0
Share

Can you post screenshot evidence that a Character$$anonymous$$otor file is in your project?

avatar image wyt3dr4g0n · Dec 13, 2013 at 09:09 PM 0
Share

alt text

charactermotorconfirm.png (56.6 kB)
avatar image wyt3dr4g0n · Dec 13, 2013 at 09:17 PM 0
Share

I should also note that I tried doing this in a new project too just to see if something may have imported funky in the original, same problem. I also get this on a different computer as well. So I'm pretty sure it's just something I'm not doing right.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by flaviusxvii · Dec 13, 2013 at 09:19 PM

http://unitygems.com/script-interaction-tutorial-getcomponent-boo/

 scriptB = GetComponent[of ScriptB]()
Comment
Add comment · Show 4 · 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
avatar image flaviusxvii · Dec 13, 2013 at 09:22 PM 0
Share

I can't imagine why you'd want to use Boo. Not that it isn't a lovely language full of character and joy.. but dang, there just isn't any documentation for it.

avatar image wyt3dr4g0n · Dec 13, 2013 at 09:31 PM 0
Share

I love python, I find the best way to for me to learn anything, languages included, is to dive right in. Thank you so much for this! I'm gonna look it over and see if I can get this to run.

avatar image flaviusxvii · Dec 13, 2013 at 09:43 PM 0
Share

I love python too, but Boo is nothing like it. The syntax is superficially similar, but otherwise it's just missing the "soul" and ease=of-use of python.

That's why I've embedded IronPython in my project.. I can straight-up write stuff like this:

 import Chroma
 import ComponentUtil
 import PyBehaviour
 import PyScript
 
 class TestReload(object):
 
     def __init__(self):
         self.chroma = Chroma(Color.red)
 
     def Update(self):
         self.chroma.shiftHue(Time.deltaTime * 20)
         self.chroma.shiftSaturation(Time.deltaTime * 15)
         self.gameObject.renderer.material.color = self.chroma.getColor()
 
     def On$$anonymous$$ouseDown(self):
         TestReload.selected = self.gameObject
 
     def OnGUI(self):
         GUI.Label(Rect(50, 50, 500, 500), self.gameObject.name)
         if GUI.Button(Rect(70, 70, 80, 20), "Reset"):
             pb = ComponentUtil.findInLineage[PyBehaviour](self.gameObject)
             pb.reset()
         if GUI.Button(Rect(70, 90, 80, 20), "Clone"):
             another = Object.Instantiate(self.gameObject,
                     self.gameObject.transform.position + Random.onUnitSphere * 3,
                     Quaternion.identity)
             another.name = "stuff %f" % Random.Range(0, 1)
         if GUI.Button(Rect(70, 110, 80, 20), "FULL"):
             PyScript.fullReset()
 
     def On$$anonymous$$ouseUp(self):
         self.gameObject.transform.Rotate(15, 0, 0)
         cam = GameObject.FindWithTag("$$anonymous$$ainCamera")
         if cam != None:
             cam.transform.Rotate(15, 0, 0)
avatar image wyt3dr4g0n · Dec 13, 2013 at 09:50 PM 0
Share

NICE! I'm a newb so I saw boo as a unity version of python. I wasn't aware I could import python directly like that! Got any tutorials on how to best go about doing that? Also, your answer worked!

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

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

Faux Gravity Prolem? #2 2 Answers

Adding multiple colliders to my character controller 1 Answer

How to set gravity for model? 1 Answer

Script Error 1 Answer


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