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 POL34 · Apr 15, 2012 at 11:35 PM · movementspherestuck

Forward movement question

Hello,

The main character of a platform game I am working on is a sphere. The only control the player has over their sphere is moving to the left or right which works fine right now. I am using a Transform.Translate function to move the ball forward at a constant speed, but because it rotates along the z axis it pushing towards the ground for part of each rotation and digs itself into the terrain and literally gets stuck. I've tried several different fixes, but none of them have worked. Any ideas?

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 IgnoranceIsBliss · Apr 16, 2012 at 12:01 AM

I think we would need to know more about your situation and the code you are using. I'm assuming you are using Unity physics (you have a Character Controller or a RigidBody on your sphere and are colliding against a Terrain?)

The most common reason for getting 'stuck' like this is that you have use Translate and thrown yourself 'into' the terrain.

Rather than using the normal translation functions, try using a CharacterMotor.

Check the code for the FPS controller and some of it's friends - you'll notice one spot where it has a line like this...

 motor.inputMoveDirection = transform.rotation * directionVector;


The CharacterMotor class knows all about avoiding collisions, sliding and avoiding terrain. By applying your user input to this rather than calling Translate, you'll give the CharacterMotor the chance to say 'No - That Will Get Me Stuck'. Instead, it will properly avoid terrain, slide down steep portions and will simulate physical properties like mass and inertia.

So if you were wanting to move your ball 'left' in response to a button press, you would say...

    motor.inputMoveDirection = new Vector3(1,0,0);


Of course, you may need to change the axis I've shown here depending on how your scene is set up. Take a look at the FPS Controller for more ideas, since it shows you a pretty basic example of how to make it work.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Movement reacting when 1 Answer

Movement Bug 1 Answer

Making a bubble level (not a game but work tool) 1 Answer

Using WASD keys instead of mouse to roll ball? 1 Answer

We have a ship that was controlled via wasd, but when we import the animation, the ship wont move. 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