I’m lost on how I should go about doing so.
At the moment I’m using the Distance joint 2d along side my controller script
public float SwaySpeed = 5.0f;
void Update()
{
if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
if (touch.position.x < Screen.width / 2)
{
transform.Translate(-Vector2.right * SwaySpeed * Time.smoothDeltaTime);
}
else if (touch.position.x > Screen.width / 2)
{
transform.Translate(Vector2.right * SwaySpeed * Time.smoothDeltaTime);
}
}
}
which simply should move the player to the right when I press on the right side of the screen and visa versa however with the 2d physics enabled when momentum builds and the player is moving to the right for example I then cannot properly move to the left and so fourth.
So How could I go about creating a script that when I press the right side of the screen the player travels in pendulum like motion till it reaches a max value i.e reaches screen boundary and then falls back to the lowest point when there is no touches registered and visa versa.
P.S I plan not to use RigidBody2d.
Thanks, if you need any additional information or want me to reword something let me know, thanks!