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 PaulX1 · Jun 30, 2010 at 03:57 PM · transformplayercharactermove

Need help getting my character to move

Hi there, I'm PaulX1, and I am new to Unity, and need some help.

I've followed this tutorial on Unitylabs.net and I have reached the 4th page, but I'm quite literally stuck. My character will fall to the ground, and then will no longer be able to move. He can animate, and turn around, but that's about it. I've adjusted the Character controller size and location, but there's no change.

I created a sphere and tested the code on that, and it appears to move properly, so could it be the animations themselves that are the problem? I think everything is lined up properly, but I may be wrong.

I've noticed that when I do this //moveDirection = transform.TransformDirection(moveDirection);, the character can move in a straight line, even animating properly, but will not go left or right. And as far as I can tell I am not getting any error messages, so it's possible it's a geometry problem, but everything is nearly completely lined up, so I don't know what it could be.

Here's the source file link. I'm not sure what's wrong, but if there's something I'm missing, please let me know. Thanks in advance.

private var walkSpeed : float = 1.0; private var gravity = 100.0; private var moveDirection : Vector3 = Vector3.zero; private var charController : CharacterController;

function Start() { charController = GetComponent(CharacterController); animation.wrapMode = WrapMode.Loop; }

function Update () { if(charController.isGrounded == true) { if(Input.GetAxis("Vertical") > .1) { if(Input.GetButton("Run")) { animation.CrossFade("run"); walkSpeed = 4; } else { animation["walk"].speed = 1; animation.CrossFade("walk"); walkSpeed = 1; } } else if(Input.GetAxis("Vertical") < -.1) { animation["walk"].speed = -1; animation.CrossFade("walk"); walkSpeed = 1; } else { animation.CrossFade("idle"); }

     // Create an animation cycle for when the character is turning on the spot
     if(Input.GetAxis("Horizontal") &amp;&amp; !Input.GetAxis("Vertical"))
     {
         animation.CrossFade("walk");
     }


     transform.eulerAngles.y += Input.GetAxis("Horizontal");

     // Calculate the movement direction (forward motion)
     moveDirection = Vector3(0,0, Input.GetAxis("Vertical"));
     moveDirection = transform.TransformDirection(moveDirection);

 }

 moveDirection.y -= gravity * Time.deltaTime;
 charController.Move(moveDirection * (Time.deltaTime * walkSpeed));

}

Comment
Add comment · Show 4
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 StephanK · Jun 30, 2010 at 04:06 PM 0
Share

If you could just post the section of the code that is supposed to move your character someone could be able to help you.

avatar image PaulX1 · Jun 30, 2010 at 04:48 PM 0
Share

I was wondering, when I made the animations for the character in 3D STudio $$anonymous$$AX, I anchored the feet to the floor, so that they wouldn't slide. Would that information also be brought into Unity?

avatar image appels · Jun 30, 2010 at 07:38 PM 0
Share

I downloaded your project and added a plane and a character controller with the walk script to the character, didn't fall through. If you want i can zip your project and upload somewhere for you to grab it.

avatar image PaulX1 · Jul 01, 2010 at 05:27 PM 0
Share

Have you sent the project yet? Please let me know when you do, thank you.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by PaulX1 · Jul 02, 2010 at 07:17 AM

The answer is that the axis of the character is different than that of the sphere, which is aligned to Unity's default axis settings. By default, X is sideways, Y is up, and Z is forwards, while the default settings for Biped in 3D Studio MAX 7 is X is sideways, Y is forwards and Z is up, meaning that this code is attempting to make the character move upwards instead of forward. So, instead of this

moveDirection = Vector3(0,0, Input.GetAxis("Vertical"));

It's instead this

moveDirection = Vector3(0,-Input.GetAxis("Vertical"),0);

The next question I have is, is there a way to change the axis of the character in Unity? I tried to change it in MAX and the whole character moved.

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 Orion_Uk · Sep 02, 2010 at 06:22 PM

Hi, I have FXB exporter version 2009.4, (in Max, during export) look under axis conversion (up axis) and change that, hope it helps ;)

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

No one has followed this question yet.

Related Questions

Problems with the movement of the player 1 Answer

2D Movement Problems 2 Answers

Opening a door at proximity 2 Answers

How to make a camera that moves with the player? 1 Answer

Unity 4.6 project in Unity 5 bug? 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