I am attempting to recreate the mechanic that allows you to swipe the sphere left and right from the game “Splashy!”.
Here is a link to its gameplay: Splashy gameplay - YouTube
Specifically, I’m interested in its fluid and responsive motion when swiping.
Thank you.
@jamiecorkhill5 Still looking for some helpful information… any idea? Did you figured it out lol?
You are looking for something like this, pseudo-code:
void Update()
{
if(TheUserIsSwiping)
{
Vector3 newPosition = ProjectTouchToWorldPosition();
sphere.transform.position = newPosition;
}
}
Vector3 ProjectTouchToWorldPosition()
{
Vector2 touchPosition = Input.GetTouch(0).position;
// Just an example. What you return here heavily depends on your setup and game design
return Vector3.one * touchPosition.x;
}
Basically you want to implement a relation between the finger position on your screen, and the player position in the 3d world. Unity’s Input class provides lots of information about the current touches on screen.
Regarding the “fluid and responsive motion”: this is where game designers and programmers spend most of their time polishing the mechanic and try to get it to “feel good”. When setting the position directly like above in the pseudo-code, you already get maximum responsiveness. To make the motion more fluid you could use smoothing operations on the position, like Vector3.Lerp() or Vector3.SmoothDamp()