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
2
Question by wrstscrnnm6 · Mar 05, 2012 at 12:12 AM · charactercontrollergravity

Custom Gravity CharacterController

I am working on a project in which we have a character moving around an Escher like space. The game is first person and the default character controller is actually almost perfect. The issue is that we need to change the orientation of the avatar so that it would be walking around the on the wall or the ceiling.

Currently we are rotating the entire environment and leaving the avatar orientation the same. This is causing issues with Unity's static batching, so we are again trying to figure out a way to rotate the player.

Question 1: Can anyone suggest an easy way to script around the default CharacterController so that we can change the direction of gravity?

Failing that I am looking for a good/free-to-use character controller script which I might modify rather than writing one from scratch. I found this one:

RigidbodyFPSWalker

but it is really glitchy and we don't actually want a physics based controller.

Question 2: Can anyone suggest a character controller script that simply duplicates the built in CharacterController? (Bonus points for JS but CS will also be fine)

----------------- EDIT -----------------

Getting global gravity to change is fairly easy. I am looking for a way to rotate the character controller So that the camera orientation and the movement will match the changed gravity.

Comment
Add comment · Show 2
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 Grespon · Jan 03, 2014 at 05:45 PM 0
Share

I need exactly this answer too..

avatar image GantZ_Yaka · Feb 11, 2015 at 02:56 PM 0
Share

I made it here, but its my own First Pirson Controller with Capsule-collider and Rigidbody attached. link text

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by ByteSheep · Mar 05, 2012 at 02:04 AM

You can edit unity gravity using:

 Physics.gravity = Vector3(0, -1.0, 0);

To change directions you can set x, y or z to a value - the vector function looks like this:

 Vector3(x, y, z);

So if you set gravity to:

 Physics.gravity = Vector3(-1.0, 0, 0);

Then the character etc will fall to the left or right.

Here's the unity documentation: http://unity3d.com/support/documentation/ScriptReference/Physics-gravity.html

I'd advise to always check there ;)

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 wrstscrnnm6 · Mar 05, 2012 at 03:15 AM 0
Share

This will be useful if we decide to include rigidbody objects in the environment but my concern is getting the orientation of the character controller to change.

Changing the global gravity either by script or via the physics manager menu does not change the way the CharacterController component behaves at all. It appears that "up" is hard coded into the 'CharacterController' component.

I will edit the question to try and be more precise.

avatar image MountDoomTeam · May 17, 2013 at 11:04 AM 0
Share

Thanks it doesnt work with character controller

avatar image
0

Answer by eneroth3 · Jan 10, 2019 at 10:01 AM

I am having the same problem. From what I can see the "gravity" direction seems to be hard coded within the character controller itself. I'm currently trying to re-create its functionality as a rigidbody controller, but if there is a way to get the character controller to use a custom vertical direction, I'd be happy to know.

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

9 People are following this question.

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

Related Questions

Gravity for my AI 0 Answers

How reliable are isGrounded checks? 1 Answer

Rpg style movement help. 2 Answers

How to add explosion force to player? 1 Answer

disable gravity on Character Controller 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