Hello everyone!
I have a question regarding player camera/controls, which involves the camera to look at the middle point between the player and the cursor like this: -----X----- and how to make the player look at the cursor but when moving to ignore moving towards the cursor.
So my 2 Questions are this:
What can I put into my code to make it so my camera focus’ in between my player and the cursor and show a prefab at the cursor location?
How can I make the player look at the cursor but ignore moving towards it?
Here is my code for moving:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(CharacterController))]
public class Controller:MonoBehaviour
{
public float MoveSpeed;
public float RotationSpeed;
CharacterController cc;
void Start()
{
cc=GetComponent<CharacterController>();
}
void Update()
{
Vector3 forward = Input.GetAxis ("Vertical") * transform.TransformDirection (Vector3.forward) * MoveSpeed;
transform.Rotate(new Vector3(0,Input.GetAxis("Horizontal") * RotationSpeed * Time.deltaTime,0));
cc.Move (forward * Time.deltaTime);
cc.SimpleMove(Physics.gravity);
}
}