Unity Android movement

Hi. I learn Android scripts. I have to create this movement:

When I hold finger on screen, my hero goes his way.

I don’t have any idea, so maybe you help me? I begin in Android.

Thanks;)

I currently have an Android project where you tap the screen to control where the player goes. You could easily change it to be holding down your finger by changing:

if (Input.GetButtonDown (“Fire1”))

to:

if (Input.GetButton (“Fire1”))

So without the details of what kind of camera view you have it’s a bit hard to answer properly. But essentially you can shoot a ray from the camera’s point of view. Where this ray hits the ground or any objects you interact with is where the player will move.

I can’t offer much beyond that simple advice despite being quite far in my games development. I wasn’t able to find any tutorials for setting up a game with these kind of controls so everything I did was just trial and error and freestyle programming.

But essentially you cast rays to determine where to go, then you must do ridiculous things to get it to work correctly and look good for your specific project, so I can’t go into those details haha.

I can give you the starting point though:

if (Input.GetButton ("Fire1"))
{

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit rayHit;

if (Physics.Raycast(ray, out rayHit, 150)
{

rayVector = rayHit.point;
				
playerDestinationVector = new Vector3 (rayVector.x, this.playerTransform.position.y, rayVector.z);

rayHitObject = rayHit.collider.gameObject;

stringRayName = rayHitObject.name;
}

That gives you the basic things you need to work with.

And after that let the madness begin…