Problems with Lerp, or Smoothing direction.

Hello,
i’m actualy working at camera control in my ThirdPerson Game.

I’m wanted to player change direction, when we are pressed the button. And i created this (with help from another questions [not my]):

var otherObject : Transform;

function Update () {

if (Input.GetAxis("Horizontal")!=0){
var newRot : Vector3;
 newRot = new Vector3 (0, otherObject.transform.eulerAngles.y, transform.eulerAngles.z);
 transform.rotation = Quaternion.Euler (newRot);}
 
if (Input.GetAxis("Vertical")!=0){
var newRota : Vector3;
 newRota = new Vector3 (0, otherObject.transform.eulerAngles.y, transform.eulerAngles.z);
 transform.rotation = Quaternion.Euler (newRota);}
}

All is working, but it was great, when this change will be smooth.
I found something like Lerp but i have problems with apply this in my code.

I’m think i must do:
Quaternion.Lerp or Vector3.Lerp.

I don’t know what to choose, i try to do something, but i have error with arguments in brackets.
It would be great if you change this to C#, I don’t like java, but when i try run this in C# i have errors after change varibles etc.

Hi,

First: translation (not that hard as you can see)

Transform otherObject;

void Update () {
   if (Input.GetAxis("Horizontal")!=0){
      Vector3 newRot;
      newRot = new Vector3 (0, otherObject.transform.eulerAngles.y, transform.eulerAngles.z);
      transform.rotation = Quaternion.Euler (newRot);
   }

   if (Input.GetAxis("Vertical")!=0){
      Vector3 newRota;
      newRota = new Vector3 (0, otherObject.transform.eulerAngles.y, transform.eulerAngles.z);
      transform.rotation = Quaternion.Euler (newRota);
   }
}

Then, answer:

Try using transform.Rotate() instead of transform.rotation

Thanks,
i translated all:

using UnityEngine;
using System.Collections;

public class SetToCam : MonoBehaviour {

public Transform otherObject ;
		
void Update () {

	if (Input.GetAxis("Horizontal")!=0)
		    {
			Vector3 newRot;
			newRot = new Vector3 (0, otherObject.transform.eulerAngles.y, transform.eulerAngles.z);
			//transform.rotation = Quaternion.Euler (newRot);
			transform.Rotate( newRot );
	}
 
	if (Input.GetAxis("Vertical")!=0)
		    {
			Vector3 newRota;
			newRota = new Vector3 (0, otherObject.transform.eulerAngles.y, transform.eulerAngles.z);
			// transform.rotation = Quaternion.Euler (newRota);
			transform.Rotate( newRota );
		}
	}
	
}

But your code, set direction to camera, when mouse is on half width of screen.
But my camera is working with Orbit. And my character is Rotating with speed like screen width/2 + degree tilt.

Can you heklp me again, i don’t know what kind of varibles i must to use. To change the rotate to rotation of camera. But no with speed of degre my roate >->> rotate camera.