- Home /
Release camera
Hello, I am developing a mobile video game and I want that when the player does not touch the screen, the camera always changes position behind the character.
The problem is that my character can rotate, that is, the coordinates of the back of my character always change and I don't know how it calculates the distance between the camera and my character adjusting to the direction.
//**
//heres the part of the code thah im working
//the camera is child of my character
Vector3 desiredPosition = (target.position - offset);
Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed);
transform.position = smoothedPosition;
transform.LookAt(target);
*//
That code works but doesnt look the back of my charcter because the constant of the offset.
Answer by dougantor · Mar 21, 2020 at 11:26 PM
transform.forward is probably what you need. (target.forward - offset)
i try it and works, but the problem is that the camera stop of follow my character.
Your answer
Follow this Question
Related Questions
Raycasting with Rotation of Camera 0 Answers
C# - Offset In-Air Camera from Current Object Position 1 Answer
Multiple Cars not working 1 Answer
add force in camera direction 1 Answer
Distribute terrain in zones 3 Answers