x


Camera Orbit Character Rotation

Hi, I've been trying to make my own character controller using rigidbodies. This is going quite well so far, but I keep bumping into one problem.

I use the ImprovedMouseOrbit script for my camera. And this all works perfectly. The only problem is, I want my character always facing where you point your camera (third person). I'm now using:

transform.rotation.y = maincam.transform.rotation.y;

To make the character face correctly, but when you rotate to around Y 180 the character doesn't rotate with the camera anymore. If you rotate even more, it well do it again but the wrong way.

I thought this basic approach was quite solid, what am I overseeing?

I've tried this with FPSController prefab and my own character controller. So I'm pretty sure it doesn't have to do with the other scripts.

more ▼

asked Apr 12 '12 at 08:36 PM

Danzou gravatar image

Danzou
220 16 27 39

You can't child the character on the camera, because of the MouseOrbit script. This means it's kinda chasing it's own tale which will bug the crap out of it. I just found out in the inspector that's the character DOES rotate it's Y rotation further, but the object in game doesn't. Is there some kind of default rotation limit?

Apr 13 '12 at 11:40 AM Danzou

Is there anyway you can show me the script of the custom rotation script. Maybe if you coud upload this to either a website or copy and paste into here. Thanks in advance (sorry i couldn't do it atm)

Apr 13 '12 at 04:02 PM JayMHelpsU

Well, I could but I found a nice work around that works just fine for me. I solved it with lookAt instead of matching the rotations. Off course I need to flip all my art 180 degrees but that won't be a problem =P

Apr 14 '12 at 02:54 PM Danzou
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

One thing i can suggest is the player to the camera (as its parent object.) The error sounds like its the way your script is set up for rotation, it probably goes in a latitude - longtitude type format. This is when 0 is the exact center and on the opposite side is 180 as the point if that makes sense. The only other problem i could think of is if this project is for flash you will get delayed mouse movement (but this never occures to me in editor mode) Good luck :) Hope this helped

more ▼

answered Apr 13 '12 at 05:24 AM

JayMHelpsU gravatar image

JayMHelpsU
120 4 6 7

(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:

x2155
x1040
x669
x30

asked: Apr 12 '12 at 08:36 PM

Seen: 724 times

Last Updated: Apr 14 '12 at 02:54 PM