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 bruu · Jan 23, 2014 at 12:00 PM · rotationplatformerobstacle

Moving with rotating object

I'm creating a simple platformer. The player is able to move only left and right. So this rotating wheel (think cylinder), is supposed to move the player towards the direction it's rotating to. So if the wheel is rotating right, the player would move right along with wheel.

I've tried making it the child of the wheel but the issue with that is that the player also rotates with the object (player moves with the wheel but also rotates around). Also I can't walk the opposite way of the rotation.

Comment
Add comment · Show 3
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 SamAgten · Jan 23, 2014 at 01:47 PM 0
Share

If I understand correctly: You have a player character that can jump on a rotating wheel. The player rotates along with the wheel, correct? I assume the player is supposed to stay upright while the cylinder/wheel rotates (otherwise parenting would do the trick)? Or are the feet of the character "glued" to the surface of the cylinder?

avatar image bruu · Jan 28, 2014 at 09:39 AM 0
Share

Yes, the player is supposed to stay upright but parenting the character causes the player to rotate.

avatar image SamAgten · Jan 28, 2014 at 09:58 AM 0
Share

O$$anonymous$$. The easiest way I can think of (on top of my head) is that you parent the player to the cylinder in any case. This should give the impression that the player is rotating along with the cylinder and his/her feet are see$$anonymous$$gly glued to the surface. If your character is doing cartwheels and revolving around its own axis (i.e. doing some sort of extra rotation) than you did something wrong with the parenting. You can easily test the required behaviour by creating two cubes, spacing them apart, parent one to the other and then change the rotation values of the transform component of the parent. Always start with a basic test, you don't need to throw in your prefabs from the get-go.

That said, if you want your character's head to keep "pointing towards the sky" during the rotation, that's a bit trickier. Start out the the same by parenting the player to the cylinder. However, this time, apply a rotation to the character equal to the rotation of the cylinder but in the opposite direction. For example: if your cylinder has a rotation of 45 degrees, your character should have a (local!) rotation of -45 to stay upright. Be sure to experiment in the editor before writing any code: use two cubes, parent them and play with their transform component to properly understand how parenting works.

Again, this is just of the top of my head. I'm at work right now. I can try to type out a decent answer (maybe throw some code and pics in the mix) to your question tonight, if you want. There are different ways to solve this though and it really depends on your situation. If you're coding a platformer and the cylinder is a wheel the player can jump on, then parenting might not be desired.

Good luck!

Sam

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Drakulo · Jan 23, 2014 at 12:16 PM

I guess setting up the wheel as child of your player will do the trick.

Comment
Add comment · Show 3 · 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 bruu · Jan 23, 2014 at 12:40 PM 0
Share

Doing that causes the wheels to move along with the player.

avatar image Drakulo · Jan 23, 2014 at 01:26 PM 0
Share

I don't get what your cylinder is for. Is it a controller for the player ?

avatar image bruu · Jan 23, 2014 at 01:54 PM 0
Share

The cylinder is rotating ( like a car wheel), so when the player goes on top- the player moves with the direction the wheel is rotating. However when made child of the wheel, the player also rotates (doing cartwheels)

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

20 People are following this question.

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

Related Questions

Getting the face direction 2 Answers

Character Controller falls through moving/rotating platforms (Not A Duplicate Post) 1 Answer

Why does my rotating platform not pause when I pause the game? 1 Answer

How to recycle obstacles in an Endless Runner? 1 Answer

Unity AI Obstacle Avoidance Help 3 Answers


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