- Home /
 
Other
need help with roll a ball like game
Hello, i need some help with my camera, i can only move it left and right. I want to be able to rotate it full 360 degrees like a third person camera, please someone look at my code and change it so it works.
Main camera code:
using UnityEngine; using System.Collections;
public class CameraMovement : MonoBehaviour {
 public float turnSpeed = 7.0f;
 public Transform player;
 public Transform PauseMenu1;
 public float height = 2f;
 public float distance = 5f;
 private Vector3 offsetX;
 void Start()
 {
     offsetX = new Vector3(0, height, distance);
 }
 void LateUpdate()
 {
     offsetX = Quaternion.AngleAxis(Input.GetAxis("Mouse X") * turnSpeed, Vector3.up) * offsetX;
     transform.position = player.position + offsetX;
     transform.LookAt(player.position);
     if (PauseMenu1.gameObject.activeInHierarchy)
     {
         turnSpeed = 0;
         
     }
     else
         turnSpeed = 7.0f;
     }
 }
 
               my player controller code:
using System.Collections; using UnityEngine.UI; using UnityEngine;
public class PlayerController : MonoBehaviour { public float speed; public float jumpHeight; public Text countText;
 public string nextLevelName;
 public int coinCountToNextLevel;
 private Rigidbody rb;
 private int count;
 private Transform camTransform;
 public jojstick joystick;
 void Start()
 {
     rb = GetComponent<Rigidbody>();
     count = 0;
     SetCountText();
 }
 void FixedUpdate()
 {
     //if (Input.GetKeyDown(KeyCode.Space)) ;
     //{
     //    rb.AddForce(Vector3.up * jumpHeight);
     //}
     Vector3 dir = Vector3.zero;
     float moveHorizontal = Input.GetAxis("Horizontal");
     float moveVertical = Input.GetAxis("Vertical");
     //dir.x = joystick.Horizontal();
     //dir.z = joystick.Vertical();
     Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
     rb.AddForce(movement * speed);
 }
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Pick Up"))
     {
         other.gameObject.SetActive(false);
         count = count + 1;
         SetCountText();
     }
 }
 void SetCountText()
 {
     countText.text = "Coins: " + count.ToString();
 }
 void Update()
 {
     if (count >= coinCountToNextLevel)
     {
         Debug.Log("Loading Next Scene");
         Application.LoadLevel(nextLevelName);
     }
 }
 
               }
Follow this Question
Related Questions
Forward and back movements with a camera emulating an isometric view 1 Answer
How do I make this Camera movement happen when I right click? 1 Answer
How to set horizon level for camera orbit script? 0 Answers
How can i make the camera look up and down through keyboard keys? 2 Answers
Stop camera from stuttering when looking straight up or down 1 Answer