- Home /
Question by
Tubestorm · May 15, 2020 at 08:28 AM ·
mobilecamera-movementcamera rotatetouch screentps
Control camera with touch field for mobile game
Hey!
I need some help, i'm designing a game for mobile and i'm having issues with finding good scripts that allow you to essentially control the players rotation, and the camera's rotation with a touch field.
here is my code for controlling character, I also tried editing it to control the character rotation, but it didn't work, so i took that out.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WorldInteraction : MonoBehaviour
{
public static WorldInteraction instance;
public UnityEngine.AI.NavMeshAgent playerAgent;
protected FloatingJoystick joystick;
public Rigidbody rigidbody;
public Vector3 velocity1;
void Start()
{
playerAgent = GetComponent<UnityEngine.AI.NavMeshAgent>();
//find joystick in scene
joystick = FindObjectOfType<FloatingJoystick>();
}
void Update()
{
//get movement from
velocity1 = new Vector3(
joystick.Horizontal * 10f,
rigidbody.velocity.y,
joystick.Vertical * 10f) ;
rigidbody.velocity = velocity1;
}
}
If you have a script that might be helpful please share, because i'm confused on how to get it to work.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612234332im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rotate camera but view should be static 0 Answers
Adapting camera movement to touch input 0 Answers
Free camera look question 2 Answers
Camera stucks at the spawn position 1 Answer