• Register
Forum Thread
  Posts  
How can i use CrossPlatformInput here for mobile to move my Character as i have to cycle through enums for direction (Forums : Support : How can i use CrossPlatformInput here for mobile to move my Character as i have to cycle through enums for direction) Locked
Thread Options
Apr 20 2019 Anchor
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;

public class PlayerController : MonoBehaviour {

    
    public float speed;
    [SerializeField]
    GameObject player;

    private MazeCell currentCell;
    private CharacterController characterController;

    public void SetLocation (MazeCell cell)
    {
        currentCell = cell;
        transform.localPosition = cell.transform.localPosition;
    }

    
    private void MovePlayer (MazeDirection direction)
    {
        MazeCellEdge edge = currentCell.GetEdge(direction);
        if (edge is MazePassage)
        {
            SetLocation(edge.otherCell);
        }
    }
    

    private void Start()
    {
        characterController = GetComponent<CharacterController>();
        
    }

    private void Update()
    {

        // How can i use CrossPlatformInput here for mobile to move my Character as i have to cycle through enums for direction
        
        if (Input.GetKeyDown(KeyCode.W))
        {
            MovePlayer(MazeDirection.North);
        }
        else if (Input.GetKeyDown(KeyCode.D))
        {
            MovePlayer(MazeDirection.East);
        }
        else if (Input.GetKeyDown(KeyCode.S))
        {
            MovePlayer(MazeDirection.South);
        }
        else if (Input.GetKeyDown(KeyCode.A))
        {
            MovePlayer(MazeDirection.West);
        }
        


    }



}


How can i use CrossPlatformInput here for mobile to move my Character as i have to cycle through enums for direction


Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.