Camera Help
I need to make my camera rotate by using the W, A, S and D keys around my target(Player.) Here is the script I am currently using which currently only follows the player. Like I said, I simply need to be able to rotate the camera around the player similar to the Runescape game, where you can rotate the camera with the keyboard. If it's not trouble, please help! Also, if your interested in helping me develop my game, which is going to be an online multiplayer rpg, please email me! trentrbtaylor@gmail.com
My script: using UnityEngine; using System.Collections;
namespace CompleteProject
{
public class CameraFollow : MonoBehaviour
{
public Transform target; // The position that that camera will be following.
public float smoothing = 5f; // The speed with which the camera will be following.
Vector3 offset; // The initial offset from the target.
void Start ()
{
// Calculate the initial offset.
offset = transform.position - target.position;
}
void FixedUpdate ()
{
// Create a postion the camera is aiming for based on the offset from the target.
Vector3 targetCamPos = target.position + offset;
// Smoothly interpolate between the camera's current position and it's target position.
transform.position = Vector3.Lerp (transform.position, targetCamPos, smoothing * Time.deltaTime);
}
}
}
Your answer
Follow this Question
Related Questions
Script for activating next GameObject after first one has been found/tracked (Vuforia) 1 Answer
OnCollisonEnter2D Not Firing after checking collider 1 Answer
How can I load/save a Prefab refference? 0 Answers
[SOLVED]Removing gameobject from list don't change the index 1 Answer
Editing animation curves in a script 2 Answers