How can change camera local position smoothly between 3 point
Hi , i have a Transform array with 3 member (cameras position) and player have camera. now i want change camera position smoothly in different situations (standing , crouching and prone) i also tired vector3d.lerp and vector3.smoothdamp and current code is:
public GameObject[] camerasPos;
Transform currentCamPos;
private float fraction = 0f;
float cameraChangeSpeed = .5f;
void Update()
{
fraction = Time.deltaTime * cameraChangeSpeed;
if (isStanding)
{
PlayerViewCamera.transform.localPosition = Vector3.MoveTowards(currentCamPos.transform.localPosition, camerasPos[0].transform.localPosition, fraction);
}
if (isCrouching)
{
PlayerViewCamera.transform.localPosition = Vector3.MoveTowards(currentCamPos.transform.localPosition, camerasPos[1].transform.localPosition, fraction);
}
if (isProne)
{
PlayerViewCamera.transform.localPosition = Vector3.MoveTowards(currentCamPos.transform.localPosition, camerasPos[2].transform.localPosition, fraction);
}
...
i also change value of cameraChangeSpeed but not affected on smooth all codes (i mean lerp and smoothdamp and mocetowards) work fine but no smoothly
Where is my mistake?
replace you moving code with this
PlayerViewCamera.transform.localPosition =
Vector3.$$anonymous$$oveTowards(PlayerViewCamera.transform.localPosition,
camerasPos[0].transform.localPosition, fraction);
and also like below
if(isStanding) {
}
else if(isCrouching) {
} else if(isProne){
}
How? i can only vote up to your comment, you must send answer but you send comment
Your answer
Follow this Question
Related Questions
Are I stupid? Vector3 1 Answer
Coin and Life magnet - What's wrong with my code? 1 Answer
Vector3.Lerp not moving object backwards 0 Answers