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 NickP_2 · Jul 16, 2013 at 01:57 AM · movementcharactercharactercontroller

Character controller wont move

I have an NPC which has a character controller attacked to it. With a c# script I generated a random position (vector3) which the NPC should move to. But when I start the game, he just holds his place.

Random position(waypoint is the random vector3):

 waypoint = new Vector3(startPos.x + Random.Range(-30, 30), startPos.y + Random.Range(-30, 30), startPos.z + Random.Range(-30, 30));

To move the NPC I've tried:

 transform.parent.LookAt(new Vector3(waypoint.x, waypoint.z, waypoint.z));
 controller.Move(transform.TransformDirection(0,0, 1));

But this doesn't work :/ Any idea's?

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 Benproductions1 · Jul 16, 2013 at 02:15 AM 0
Share

Do you get any errors?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Mill0698 · Jul 16, 2013 at 03:58 AM

This might not help by try

movDir = transform.forward * movementSpeed;

controller.Move(movDir*Time.deltaTime);

Comment
Add comment · Show 3 · 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 Benproductions1 · Jul 16, 2013 at 04:25 AM 0
Share

His problem is that he's trying to pass 3 integers as the arguments for TransformDirection. Not a Vector3

avatar image NickP_2 · Jul 16, 2013 at 02:56 PM 0
Share

Thanks for the reply, @Benproducts, yes i'm passing 3 integers, but I convert them to a vector3, so that woulnd hurt right?

avatar image Benproductions1 · Jul 16, 2013 at 11:34 PM 0
Share

@NickP No you are not converting them. Converting them would be writing Vector3(0, 0, 1) (aka Vector3.forward), not just (0, 0, 1). Do you get any errors?

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

Character Controller problem 0 Answers

CharacterController NullReferenceException dispite attached to object 1 Answer

[C#]CharacterController Turning 2 Answers

change move controls relative to player 1 Answer

Background & sprites are smearing towards the player during movement. Help determine the cause and solution? 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