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?

Can you post screenshot evidence that a CharacterMotor file is in your project?

[19300-charactermotorconfirm.png|19300]

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 Answer

1
scriptB = GetComponent[of ScriptB]()

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.

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.

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!