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 LegolasArc · Mar 17, 2012 at 06:39 PM · movementmodel

Movement doesnt work if I rotate my model

Hi!

I am having some troubles with my movement script. If I test it with a normal cylinder and a character controller mesh it works fine. The problem is, when I import my model to the scene, it changes the axis or something like that.

If I import and select all rotate values to 0 (as image): it works (of course the character is lied) http://img820.imageshack.us/img820/4668/sinrotaar.jpg

If I try to rotate the character in the position I want: http://img839.imageshack.us/img839/1065/sinrotar.jpg

It doesnt work. I think is something related to the axis, cos I only can Jump.

I add my movement script maybe I'm doing something wrong (I know my code is not the best, but I'm still starting and I have to learn a lot).

 function Update () {
 var controller : CharacterController = GetComponent(CharacterController);        
 var right : Vector3 = transform.right * speed * Input.GetAxis("Horizontal");
 var forward : Vector3 = transform.forward * speed * Input.GetAxis("Vertical");
 
     
 right.y = moveDirection.y; // keep current vertical velocity
 right.z = forward.z;  // z z
 moveDirection = right; // but update horizontal velocity
 
 //Doble salto
 if (controller.isGrounded) {  //If the player is on the floor
     contadorsalto = 0;             //Reset the counter
     moveDirection.y = 0;
     if (Input.GetButtonDown ("Jump")) {  //When press space
         moveDirection.y = jumpSpeed;  //Jump
         contadorsalto = 1;             //Counter = 1
     }
 } else {                            //If the player is NOT on the floor
     if (contadorsalto < 2) {        // and the counter is less than 2 (only 1 jump)
         if (Input.GetButtonDown ("Jump")){  //When we press space
             moveDirection.y = jumpSpeed;  //Jump
             contadorsalto = 2;                //Counter = 2 so it won't enter again until player is in the floor 
         }
     }
 }

 moveDirection.y -= gravity * Time.deltaTime;

 controller.Move(moveDirection * Time.deltaTime);
 

}

Thanks in advance!

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by hijinxbassist · Mar 17, 2012 at 07:32 PM

Very common problem, i would get soo frustrated with this. All you need to do is set the pivot of your model so that Y points up, and Z points forward. In 3dsMax, you go to Affect Pivot Only and rotate it accordingly.

I didnt specify before, this will be done in the modeling program itself and not in unity. If youre not sure how to do this, do a "Search engine" search for your modeling program and how to change pivot of model.

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
avatar image
0

Answer by LegolasArc · Mar 18, 2012 at 06:22 AM

Perfect, it works , thanks a lot! Greetings

Comment
Add comment · Show 1 · 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 hijinxbassist · Mar 18, 2012 at 07:35 AM 0
Share

Glad to here it! It took me a little why to understand why this was happening, but once you do you'll never forget :p Can you mark the question as answered please, the lil checkmark under the thumbs. Its also better to respond using comments ins$$anonymous$$d of answers. Happy trails

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Difference between Legacy, Humanoid and Generic model 2 Answers

Whats the script for basic Character movement? 2 Answers

Smooth Camera Follow Script, Weird Movement... Please help! 1 Answer

Character running at super speed 1 Answer

(23,34): BCE0019: 'SetButton' is not a member of 'UnityEngine.Animator'. 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