Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 McMutton · May 28, 2011 at 12:43 AM · movementfbxdirectionaxes

Raycast using Transform.Up issue - FBX Model from Messiah

Gentlemen.

Currently, I'm writing up my own, simpler movement code for use in my projects, and have run into a snag. I've a bit of code that uses a Ray to check whether there's ground beneath you, altering an onGround variable to true or false based on its findings:

 var onGround : boolean;
 
 if(Physics.Raycast(transform.position, -transform.up, 1)) {
         onGround = true;
     }
     else {
         onGround = false;
         }

This bit works just fine when the script is attached to a random cube, but doesn't seem to DO anything when I attach it to an FBX model I exported from Messiah Studio. Another issue is the movement part of the code:

 rlMovement = Input.GetAxis("Horizontal");
 
     if (rlMovement) {
         transform.Translate(transform.right * rlMovement * Time.deltaTime * moveSpeed);
         
             if(Input.GetButtonDown("Dash"))
                 rigidbody.AddForce(Vector3(5 * rlMovement, 0, 0), ForceMode.Impulse);
     }


When attached to a cube, it works just fine; Pressing D moves it right, pressing A moves is left. But when attached to said Messiah model, the movement is reversed. Are the axes getting screwed up on export or something? Should I take the issue to a Messiah-based forum instead?

~FIXED~

So I was able to fix the second issue by messing with the centers and whatnot in various export settings that it went through. Good solution, understandable enough. But the first issue was solved by... Adding another, completely unrelated boolean variable. Which is rather odd, to say the least...

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Wolfram · May 28, 2011 at 02:00 AM

Physics.Raycast requires colliders to work.

In the import settings of your FBX model, set the "generate mesh colliders" checkmark.

EDIT: just noticed the second part of your question. Check if there are any transformations at the top level, when selecting your object in the project view. If there are, you should make sure that there aren't any (pos=0/0/0, rot=0/0/0, scale=1/1/1). I can tell you precisely how, though, since I don't know Messiah, and every modeling program behaves differently in that regard.

Also, every modeling program uses a different coordinate system, and most of the time these differ from Unity's left-handed Y-up system. If Messiah uses a right-handed system, your models will most likely be mirrored. Does the model look all right in Unity?

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 McMutton · May 28, 2011 at 05:14 PM 0
Share

I was able to solve both issues, as noted above. $$anonymous$$ostly by messing with export settings. Thanks for the help, though!

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

2 People are following this question.

avatar image avatar image

Related Questions

Custom movement script problems 1 Answer

Camera relative movement 0 Answers

Get which way the player is moving from character controller.move 2 Answers

How do I make an object in game face the direction it's traveling while viewing from above? 1 Answer

fbx character bones rotate opposite direction in unity 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