- Home /
Question by
Archelous · May 12, 2018 at 03:37 AM ·
c#unity 5cameramouseposition
MousePosition with Iso camera movement
Hello everyone,
Im having a weird bug with my isometric camera, this returns the perfect point that i am clicking until my camera starts to follow my player. Camera is Orthographic with a 30x, 45y rotation.
Click code:
Plane normal = new Plane (Vector3.up, new Vector3(0f, 0f, 0f));
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
Vector3 targetPoint = new Vector3 ();
float hitDistance = 0f;
if(normal.Raycast(ray, out hitDistance)) {
targetPoint = ray.GetPoint(hitDistance);
}
Debug.DrawRay (characterTransform.position, targetPoint, Color.red, 200f);
Camera follow code:
void LateUpdate () {
Vector3 targetCamPos = target.position + offset;
transform.position = Vector3.Lerp (transform.position, targetCamPos, smoothing * Time.deltaTime);
}
Comment
Best Answer
Answer by Archelous · May 12, 2018 at 01:00 PM
For anyone having the same issue the solution in the end was i had to subtract the camera position from the target point, I have no idea why this is but if someone could enlighten me that would be great. Thanks
Your answer
Follow this Question
Related Questions
How to detect an object which be in FOV of certain camera ? 1 Answer
how to switch cameras C# 0 Answers
Switching from a cinematic cycle to the player camera 0 Answers
Distribute terrain in zones 3 Answers
Camera up and down on TouchField 1 Answer