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 Lucas · Jan 26, 2011 at 06:26 AM · gravitymariofauxgravity

Character Controller and Camera for Faux gravity..(Mario Galaxy)

So many people ask the question about Mario Galaxy, and I spend my spare time to create the same effects.I read their request and question, and I decide to use

transform.rotation = Quaternion.FromToRotation (Vector3.up, (transform.position - Vector3.zero).normalized); 

to rotate my character, and it works. But there is a problem, the collision capsule of Character Controller do not rotate, it makes a lot of trouble about collision, such as hit the barricade.

looks like this:

alt text

Secondly, about the camera, I want to put my camera in front of the character, even though the character have rotated. Does it have any function I can use??

Thanks for your help!!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by runevision · Jan 26, 2011 at 10:04 AM

If you need a variable gravity / up direction for your character, you need to use a Rigidbody with a Capsule Collider and not a CharacterController. Rotating CharacterControllers around anything other the Y axis just doesn't work, and rotating the entire world is very sub-optimal and error prone physics-wise.

The Locomotion System project has a demo scene with a character with variable up direction, so that's one example of how to do it.

Comment
Add comment · Show 2 · 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 Lucas · Jan 26, 2011 at 10:40 PM 0
Share

Thanks Rune Skovbo Johansen, I will download that project to figure out how to make it.. I am very appreciated..

avatar image onlineight · Jun 14, 2020 at 08:14 PM 0
Share

I was trying the same thing, and rigidbody doesn't work well because of velocity e.g. when I fall down a slope, my character keeps moving.

avatar image
1

Answer by Jesse Anders · Jan 26, 2011 at 06:33 AM

Yes, the collider for the character controller does not rotate, which makes the character controller component less than suitable for this particular application.

If everything else is working more or less the way you want, the easiest solution (although not an ideal one) would probably be to adjust the capsule parameters to make it a sphere. Obviously a sphere is a poorer approximation of a typical humanoid shape than a capsule, but I imagine it could work, depending on the circumstances.

Comment
Add comment · Show 2 · 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 Lucas · Jan 26, 2011 at 06:37 AM 0
Share

Ha, my friend tell that few days ago, but I hope I can find "precisely" solution for it. and I believe the collide would more accurate. How about the camera one? can you give me some advices?

avatar image runevision ♦♦ · Jan 26, 2011 at 09:59 AM 1
Share

Adjusting the CharacterController height to be a sphere won't work correctly. The CharacterController handles ground and walls differently. No matter if the shape is a sphere, settings like Slope Limit and Step Offset still assumes that Y is up.

avatar image
1

Answer by rob49152 · Jan 26, 2011 at 07:49 AM

Instead or rotating the character which will cause the problems you describe. I'd rotate the universe around the character and then rotate the camera back the opposite way. This should have the same effect that you want but the characters feet will remain the bottom of the character controller.

If you parent everything in the 'universe' to an emtpy game object, then reverse what you want the characters angle to be, then reverse the cameras z rotation it should work... in theory... in my brain it does.

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 Jesse Anders · Jan 26, 2011 at 07:59 AM 2
Share

Not sure about that; transfor$$anonymous$$g the world to give the effect of a camera transformation is rarely the optimal solution. Also, although it might work, I imagine constantly rotating/moving every collider in the simulation other than the character controller would be a bit of a stress test for the physics engine. (Rotations are typically more difficult to handle as far as collision detection goes than linear motion against static objects.)

avatar image Eric5h5 · Jan 26, 2011 at 10:30 AM 0
Share

Jesse's right; and especially moving static colliders is rather a no-no if you want performance.

avatar image Lucas · Jan 26, 2011 at 10:37 PM 0
Share

So, do you have any good solution have good performance and same effect? I try it if I fix the character's position, there are no collision happened(the barricade is trigger), that's why I make the surface ball fixed, and character walk on the ball surface. $$anonymous$$aybe I should try to fix the character and camera, when I press forward, just set surface ball rotate faster... does it works?

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

1 Person is following this question.

avatar image

Related Questions

Mario Galaxy -ish controls problem 1 Answer

Faux Gravity, spinning at bottom of sphere 0 Answers

Trying to figure out how to translate these gravity script to Javascript 2 Answers

Multiple Planets with their own gravitational pull 1 Answer

Click to move player while avoiding jitter at edges 0 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