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?