x


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!!

more ▼

asked Jan 26 '11 at 06:26 AM

Lucas gravatar image

Lucas
9 6 7 13

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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.

more ▼

answered Jan 26 '11 at 10:04 AM

runevision gravatar image

runevision ♦♦
8.1k 29 46 112

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

Jan 26 '11 at 10:40 PM Lucas
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jan 26 '11 at 06:33 AM

Jesse Anders gravatar image

Jesse Anders
7.3k 7 17 48

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?

Jan 26 '11 at 06:37 AM Lucas

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.

Jan 26 '11 at 09:59 AM runevision ♦♦
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jan 26 '11 at 07:49 AM

rob49152 gravatar image

rob49152
11 1

Not sure about that; transforming 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.)

Jan 26 '11 at 07:59 AM Jesse Anders

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

Jan 26 '11 at 10:30 AM Eric5h5

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. Maybe I should try to fix the character and camera, when I press forward, just set surface ball rotate faster... does it works?

Jan 26 '11 at 10:37 PM Lucas
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x464
x20
x10
x1

asked: Jan 26 '11 at 06:26 AM

Seen: 1970 times

Last Updated: Jan 26 '11 at 06:33 AM