• 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 Wuzseen · Aug 21, 2012 at 05:44 PM · animationcharacter controllersidescrollercharacter motor

Character Controller/Motor Falling Through Animated Platforms

Hey all,

I'm working on a sidescroller controller and I've gone through a couple iterations with varying success. At first I did it from scratch with a rigidbody and forces, next I tried using the character controller. The character controller by itself caused issues when I wanted to move along animated platforms that go up and down or left and right. That is to say, you would simply fall through them!

The solution at first seemed to be adding a character motor. And this definitely worked, at least, part of the way.

However I still sometimes fall through the platforms. In fact, I do so very often--especially the vertically moving platforms.

             moveDirection = new Vector3( x, 0, 0 );
             
             if( x != 0 && x < 0 )
                 x = -1;
             else if( x != 0 && x >0 )
                 x = 1;
             
             if( x != lastX && x != 0 ) { // Look left/right depending on direction
                 model.transform.forward = new Vector3( x, 0, 0);
             }
             
             modelController.stillOrMove = x;
             
             lastX = x;
             
             moveDirection = transform.TransformDirection(moveDirection);
             moveDirection *= speed;
             if (controller.isGrounded) {
                 vertSpeed = 0;
                 if (Input.GetButton("Jump"))
                     vertSpeed = jumpSpeed;
                 
             }
             vertSpeed -= gravity * Time.deltaTime;
             moveDirection.y = vertSpeed;
             controller.Move(moveDirection * Time.deltaTime);

So there's the main character controlling code. The code dealing with x is just how I've made it so that my model, which is a child of the character controller, flips in accordance with the direction I am moving (looks left/right properly).

http://i.imgur.com/Hrwzm.png

There's a picture of the game, the platform the character is on is one such animated platform that I often fall through.

I've tried a couple things, such as parenting a slightly larger collider to the animated mesh, yet this still results in the same problems. I've fiddled with the moving platform stuff on the character motor, but no dice.

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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Customizing mocap data for modified jump ??? 0 Answers

How to make pre-recorded character movements, then have them playout during a scene? 0 Answers

Can I make animations snap to a frame? 2 Answers

how can make combat attack with different dmg? 1 Answer

how to stop the whole game but not the death animation when player dies 3 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges