- Home /
RTS Camera problem.
Hello.
So, after it turned out that my last question wasn't specified enough, I decided to write this one, this time with some actual code and better description of the problem.
Here's the code's fragment (the one with the problem):
using UnityEngine;
using System.Collections;
public class GalCamv2 : MonoBehaviour {
public Transform Cam;
public Transform Parent;
public float ySpeed = 400f;
public float xSpeed = 400f;
private float x;
private float y;
public float MinDis = 75f;
void Start () {
}
void Update () {
if(Input.GetMouseButton(0) & PauseChange == 0f){
Cam.parent = Parent;
x+=Input.GetAxis("Mouse X") * xSpeed * 0.02f ;
y-=Input.GetAxis("Mouse Y") * ySpeed * 0.02f ;
Vector3 CamLocPos = new Vector3 (-x, MinDis, y);
Cam.localPosition = CamLocPos;
}
}
Here's the problem: after starting the game and "grabbing" for the first time the camera adjusts it's position to the parent's position. Is there any way to avoid that, so the camera stays in the same position as it was before giving it the parent for the first time?
-Xentarok
P.S: After fixing this issue and few other I am going to release full code for free.
Your answer
Follow this Question
Related Questions
Camera rapidly changes it's position when the parent changes. 0 Answers
Local Velocity for Rigidbody? 1 Answer
Maya objects with different transforms. 1 Answer
Get child position in world space 4 Answers
RTS Mouse Click Movement 1 Answer