#Help
1 messages · Page 1 of 1 (latest)
Im making a multidimensional platformer and i want the camera to move from a specific place to another when its orthographic and move back when its perspective
Even the rotation
This is not enough info
And I won't just give you code
Go program it
When you're stuck, ask
I did lerping but just doesnt work
I've no idea in which context you used lerping
And I still need more info on how you want this
Perhaps drawing it would help
public class CameraScript : MonoBehaviour
{
Camera cm;
Vector3 startPos = new Vector3(0, 1, -10.5f);
Vector3 endPos = new Vector3(-8, 4.5f, -7);
Vector3 tempPos;
float duration = 3f;
float elapsedTime;
void Start()
{
cm = Camera.main;
cm.orthographic = true;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
cm.orthographic = !cm.orthographic;
if (cm.orthographic)
{
startPos = new Vector3(0, 1, -10.5f);
endPos = new Vector3(-8, 4.5f, -7);
}
if (!cm.orthographic)
{
startPos = new Vector3(-8, 4.5f, -7);
endPos = new Vector3(0, 1, -10.5f);
}
}
elapsedTime += Time.deltaTime;
float percentage = elapsedTime/duration;
transform.position = Vector3.Lerp(startPos, endPos, Mathf.SmoothStep(0, 1, percentage));
}
}
@glad lantern here
it also moves when starting the game
i dont want it to happen
if (cm.orthographic)
{
startPos = new Vector3(0, 1, -10.5f);
endPos = new Vector3(-8, 4.5f, -7);
}
if (!cm.orthographic)
{
startPos = new Vector3(-8, 4.5f, -7);
endPos = new Vector3(0, 1, -10.5f);
}
The latter should be else
if (cm.orthographic)
{
startPos = new Vector3(0, 1, -10.5f);
endPos = new Vector3(-8, 4.5f, -7);
}
else
{
startPos = new Vector3(-8, 4.5f, -7);
endPos = new Vector3(0, 1, -10.5f);
}
From what I understand you just want the camera to move up?
i want it to move from start pos to end pos and rotate it so it faces the level
and i want it to move only if i click space
Use this
in the update?
i want something that can be used in my own function
??
@glad lantern ?
can u help?