all repos — RPG @ 502924ae35666f2d5ac541310b3e57f2e4fe70b4

Fully functional 3D turn based role playing game coded in C# and base Unity.

Assets/Scripts/Overworld/Orbit.cs (view raw)

 1using UnityEngine;
 2using System.Collections;
 3
 4public class Orbit : MonoBehaviour
 5{
 6
 7    public float turnSpeed = 150.0f;
 8    public Transform player;
 9
10    public Vector3 offset;
11
12    void Start()
13    {
14        //offset = new Vector3(player.position.x, player.position.y + 2.0f, player.position.z + 7.0f);
15        //offset = new Vector3(10, 10, 10);
16    }
17
18    void LateUpdate()
19    {
20        offset = Quaternion.AngleAxis(Input.GetAxis("Mouse X") * turnSpeed * Time.deltaTime, Vector3.up) * offset;
21        //offset = Quaternion.AngleAxis(Input.GetAxis("Mouse X") * turnSpeed, Vector3.up) * offset;
22        transform.position = player.position + offset;
23        transform.LookAt(player.position);
24    }
25}