Cant get figgure of 8 algorithm to work

I am trying to create a figgure of 8 algorithm for weapon bob, it makes a semi figgure of 8 shape but isnt exactly what i want,

attached to a camera:

``````using UnityEngine;
using System.Collections;

public class c : MonoBehaviour {

Vector3 currentCamPosition;
float m_PhaseX = 0f;
float m_PhaseY = 0f;
float m_Speed = 2f;
float m_x = 1f;
float m_y = 2f;

bool m_Invert = true;
bool m_InvertY = true;

void Start()
{
currentCamPosition = transform.position;
}
// Update is called once per frame
void Update ()
{

if (m_Invert)
{
m_PhaseX = Mathf.Lerp (m_PhaseX, m_x, Time.deltaTime * m_Speed);

if(m_PhaseX > m_x * 0.95)
{
m_Invert = false;
}
}
else
{
m_PhaseX = Mathf.Lerp (m_PhaseX, -m_x, Time.deltaTime * m_Speed);

if(m_PhaseX < -m_x * 0.95)
{
m_Invert = true;
}
}

if (m_InvertY)
{
m_PhaseY = Mathf.Lerp (m_PhaseY, -m_y, Time.deltaTime * m_Speed);

if(m_PhaseY > -m_y * 0.95)
{
m_InvertY = false;
}
}
else
{
m_PhaseY = Mathf.Lerp (m_PhaseY, m_y, Time.deltaTime * m_Speed );

if(m_PhaseY > m_y * 0.95f)
{
m_InvertY = true;
}
}

currentCamPosition.x = Mathf.Sin(m_PhaseX) / 1;
currentCamPosition.y = Mathf.Cos(m_PhaseY) / 1;

UpdateCam ();
}

public void UpdateCam()
{
transform.localPosition = Vector3.Lerp (transform.localPosition, currentCamPosition, Time.deltaTime);
}
}
``````

Anyone got a working figgure of 8 algorithm that produces what i am looking for?

This might be of some help: http://forums.tigsource.com/index.php?topic=16493.0

The code you posed was correct but it was turned 90 degrees. I have fixed the code:

``````		m_PhaseX += Time.deltaTime * m_Speed;

currentCamPosition.x = Mathf.Sin(m_PhaseX) * m_Scale * 2.5f;
currentCamPosition.y = Mathf.Sin(m_PhaseX * 2f) * m_Scale;

UpdateCam ();
``````

This yields the result:

Bingo, the lerp was causing the distortion, the curves are now uniform. Thanks for the help guys.