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 twinmoon1 · Jun 11, 2013 at 10:13 AM · errormovementmotor

What is movementmotor and how do I fix it?

I picked up this script from a free unity program but it is telling me it does not recognize MovementMotor. how do I fix this and what do I replace it with. here is the script that I have where movementmotor is used. it is from the angry bots tutorial from unity. The error message I get is

 assets/Standard Assets/Scripts/AI scripting/AttackMoveController,js(4,20): BCE0018: The name 'MovementMotor' does not denote a valid type ('not found').

The code I use is:

 #pragma strict
 
 // Public member data
 public var motor : MovementMotor;
 
 public var targetDistanceFront : float = 2.5;
 public var targetDistanceBack : float = 1.0;
 
 public var weaponBehaviour : MonoBehaviour;
 
 // Private memeber data
 private var character : Transform;
 private var nextPatrolPoint : int = 0;
 
 private var player : Transform;
 
 private var goingRight : float = 1;
 private var directionChangeTime : float = 0;
 
 function Awake () {
     character = motor.transform;
     player = GameObject.FindWithTag ("Player").transform;
 }
 
 function OnEnable () {
     if (weaponBehaviour)
         weaponBehaviour.enabled = true;
 }
 
 function OnDisable () {
     if (weaponBehaviour)
         weaponBehaviour.enabled = false;
 }
 
 function Update () {
     // Calculate the direction from the player to this character
     var playerToCharacterDirection : Vector3 = (character.position - player.position);
     //playerToCharacterDirection.y = 0;
     playerToCharacterDirection.Normalize ();
     
     // Set this character to face the player,
     // that is, to face the direction from this character to the player
     motor.facingDirection = -playerToCharacterDirection;
     
     // Calculate the angle in degrees this character is away from the front of the character.
     // If this character is in front of the player, the angle is 0,
     // to the side is 90 and behind is 180.
     var degreesFromPlayerForward : float = Vector3.Angle (playerToCharacterDirection, player.forward);
     
     // If not almost directly in front of the player, base the direction on what
     // is the shortest route to get behind the player: Left or right way around.
     if (degreesFromPlayerForward > 30) {
         goingRight = Mathf.Sign (Vector3.Dot (-playerToCharacterDirection, player.right));
         directionChangeTime = Time.time;
     }
     // If this character has stayed in front of the player for more than a little while,
     // change direction to the other way around. This avoids some cases of the character
     // getting stuck while the player is aiming at him.
     else if (Time.time > directionChangeTime + 0.8) {
         goingRight = -goingRight;
         directionChangeTime = Time.time;
     }
     
     // behindFactor is how much this character is behind the player.
     // 0 degrees is a value of 0 and 90 degrees or more is a value of 1.
     var behindFactor : float = Mathf.InverseLerp (0, 90, degreesFromPlayerForward);
     
     // Lerp the target distance between the front and back target distances based on the behindFactor
     var targetDistance : float = Mathf.Lerp (targetDistanceFront, targetDistanceBack, behindFactor);
     
     // Calculate the targetPosition
     var targetPosition : Vector3 = player.position + playerToCharacterDirection * targetDistance;
     
     // If this character is not already behind the player, strafe sideways to get behind
     if (degreesFromPlayerForward < 120)
         targetPosition += character.right * goingRight;
     
     // Calculate the target vector that this character should move along
     // to reach the target position
     var targetVector : Vector3 = targetPosition - character.position;
     targetVector.y = 0;
     
     // Make sure the target vector doesn't exceed a length if one
     if (targetVector.sqrMagnitude > 1)
         targetVector.Normalize ();
     
     // Smooth the movement direction a bit so this character doesn't change direction abruptly
     motor.movementDirection = targetVector;
 }
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 Graham-Dunnett ♦♦ · Jun 11, 2013 at 10:16 AM 0
Share

I formatted your code for you. Please learn to do this.

avatar image InfiniBuzz · Jun 11, 2013 at 10:23 AM 0
Share

You need to add the movementmotor class to your project. It should be delivered with the code you got here. Also make sure the class names are the same as the script name in your project view. What class is the code you posted in?

avatar image twinmoon1 · Jun 11, 2013 at 09:27 PM 0
Share

I am going to school right now to learn how to code. That's why right now I am using scripts from different games so I can study them and learn from them.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Graham-Dunnett · Jun 11, 2013 at 10:20 AM

MovementMotor.js is one of the scripts from the AngryBots demo. I guess your Unity project is missing this. I think also that you copied AttackMoveController.js from this demo, so just copy over the other script too. We'd say that AttackMoveController.js depends on MovementMotor.js.

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

16 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

Related Questions

BCE0044: Expecting : Found = Error! 2 Answers

Error with code, cannot figure out solution... 1 Answer

Expecting EOF Found } 3 Answers

Mathematicle error help 1 Answer

Expecting ':' Found '=' 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