So this is my code.
[SerializeField] float PositionPitchFactor = -5f;
void Start()
{
}
void Update()
{
ProcessTranslate();
ProcessRotation();
}
private void ProcessRotation()
{
float pitch = transform.localPosition.y * PositionPitchFactor;
float yaw = 0f;
float roll = 0f;
transform.localRotation = Quaternion.Euler(pitch, yaw, roll);
}
private void ProcessTranslate()
{
//Movement
//Horizontal
float xThrow = CrossPlatformInputManager.GetAxis("Horizontal");
float xOffset = xSpeed * xThrow * Time.deltaTime;
float rawXPos = transform.localPosition.x + xOffset;
float ClampedXPos = Mathf.Clamp(rawXPos, -82.5f, -61.5f);
//vertical
float yThrow = CrossPlatformInputManager.GetAxis("Vertical");
float yOffset = ySpeed * yThrow * Time.deltaTime;
float rawYPos = transform.localPosition.y + yOffset;
float ClampedYPos = Mathf.Clamp(rawYPos, -335f, -325.5f);
transform.localPosition = new Vector3(ClampedXPos, ClampedYPos, transform.localPosition.z);
}
}
and heres a video
This was on exactly 3 minutes into the lesson that this happened when Ben tried it out that this happened to me. My hands are up on this one because the only logical thing i can think of thats the problem is my hard coded values but i havent found a solution for that yet