- Home /
Please help me finish my 3rd person rigid body controller!
Hello, I am an artist trying to cobble a game together with what little understanding I can attain of this language. I would like some advice on what steps I would take to modify the following script for two different uses.
var target : Transform;
var damping = 6.0;
var smooth = true;
@script AddComponentMenu("Camera-Control/Smooth Look At")
function LateUpdate () {
if (target) {
if (smooth)
{
// Look at and dampen the rotation
var rotation = Quaternion.LookRotation(target.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
}
else
{
// Just lookat
transform.LookAt(target);
}
}
}
function Start () {
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
First, what it does now: http://xaler.web44.net/test.html
What I'd like it to do is only rotate the character on the vertical (Y?) axis, and only rotate the character when the right mouse button is held down. This version of the code would be applied to the character and control motion.
The second version would be applied to the head, with constraints so that it doesn't break, like snapping back to front after the object leaves 180 degrees of sight. It would be active at all times unlike the first one.
Anyone with any advice on what steps I should take to achieve this, would be my hero, as with completing those goals I'll of finished piecing together a rigidbody character controller from a few simple scripts (they need some tuning, I'm bad at this).
Any feedback is appreciated, thank you!