- Home /
Question by
Ekta-Mehta-D · Mar 22, 2014 at 11:25 AM ·
cameramultiplayerphoton
Photon : Multiplayer car race game Camera Set
hello everyone..
i am using photon realtime multiplayer plugin. and i have check worker demo..
In that demo they have third person controller script and third person camera script. Both are attached to the player..
I have created script for controlling car.. and camera is also following car very well..
here is my camera script :
using UnityEngine;
using System.Collections;
public class NewCamera : MonoBehaviour {
#region Private Variables
[SerializeField]
private float distanceAway;
[SerializeField]
private float distanceUp;
[SerializeField]
private float smooth;
[SerializeField]
private Transform follow;
private Vector3 targetPosition;
private Vector3 velocity = Vector3.zero;
public float smoothing = 10;
#endregion
#region Properties (public)
#endregion
float angleBetween = 0.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
Application.Quit();
}
//}
//void LateUpdate()
//{
targetPosition = follow.position + follow.up * distanceUp - follow.forward * distanceAway;
float T = Time.deltaTime * 2;
Debug.DrawRay(follow.position,Vector3.up * distanceUp, Color.red);
Debug.DrawRay(follow.position,1f * follow.forward * distanceAway, Color.blue);
Debug.DrawLine(follow.position,targetPosition,Color.yellow);
transform.position = Vector3.Slerp(transform.position,targetPosition,smooth * Time.deltaTime);
transform.position = Vector3.SmoothDamp(transform.position,targetPosition,ref velocity,10);
transform.LookAt(follow);
}
}
now wen i attach my this camera script and car controller script.. , but code is not working.. camera does not follow my car..
Comment
Your answer
Follow this Question
Related Questions
Problem with PhotonView.RPC 4 Answers
Photon IsMine not working? 1 Answer
how do get camera, scene enemy in photon unity ? 0 Answers
Cursor GUITexture 1 Answer
[Closed]multiplayer camera script 2 Answers